Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Tag Cloud
access acer asus batch bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard mouse network printer problem ram registry router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
Creating dynamic hyperlinks in Word - embedding fields inside fields using VB

Reply  
Thread Tools
Gavrilo Princip's Avatar
Junior Member with 1 posts.
 
Join Date: Jan 2009
07-Jan-2009, 05:17 PM #1
Creating dynamic hyperlinks in Word - embedding fields inside fields using VB
I am trying to create links to specific locations with each document between two documents. The document names will change. I can update the current name of the other document by creating a custom property called "otherDoc". I have solved most problems, however, I am unable to insert a field into the address of the link (to make the link dynamic) without utilizing the showfieldcodes command (which is very memory and time consuming since the documents I am working on are very large). Below is my code. I was wondering if there is any way to set the address as a field? Or somehow input an address and it would be understood by word to be field.


Sub link_to_other()

'pastes hyperlink to the other document
Selection.PasteSpecial Link:=True, DataType:=wdPasteHyperlink, Placement:= _
wdInLine, DisplayAsIcon:=False

'selects the hyperlink that was just inserted
Set myField = Selection.PreviousField

'creates variables
Dim temp_address As String
Dim temp_subaddress As String

'sets variables
temp_address = ActiveDocument.CustomDocumentProperties("otherDoc").Value & ".doc"
temp_subaddress = Selection.Range.Hyperlinks(1).SubAddress

'changes the hyperlink the the dynamic value
Set SCut = ActiveDocument.Hyperlinks.Add( _
Anchor:=Selection.Range, _
Address:=temp_address, SubAddress:=temp_subaddress)
End Sub

Last edited by Gavrilo Princip; 07-Jan-2009 at 05:17 PM.. Reason: formatting
Reply

Tags
fields, macro, visual basic, word

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:13 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.