Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting Hyperlink to Word

Status
Not open for further replies.

infinitx

Technical User
Feb 26, 2004
212
US
Hi,

I want to export a hyperlink to word. Everything works, it exports the hyperlink to word, but when it is in word, it is no longer a hyperlink (no longer underlined), its just text. It looks like this: "C:\Image\Image1.jpg". How could I make it that it transfers the hyperlink while keeping its hyperlinking property? Better yet, how could that hyperlink be replaced by the image that it hyperlinks?

Thanks,
Alex
 
FILE Hyperlink Syntax

Hyperlinks are the blue text you see on emails, websites, etc that when selected open the directoy (or document, assuming you have it installed on your PC (WORD, ACROBAT, Excel) or point you to the respective directoy where the file or files are located. This reduces the need for transmitting files back and forth via email only to end up with 10 copies of the same file. Therefore, I want everyone to become familiar with the following Hyperlink Syntax we need to use.

Assumptions:
All users have access rights (read, modify, create, etc) to the directory (i.e. location) of the file or files in question.

Use the following to UNC (Universal Naming Conventions) designation direct someone to a directory or file on our network.

To point somone to a directory use:
file://\\f:\management
To point somone to a file use:
<file://\\F:\management\2003 CHAP Guidelines.PDF>
This will locate the file and start the appropriately linked applocation (i.e files ending in PDF=Acrobat, DOC=Word, XLS=Excel, etc..)
Note: The < > symbols designate this as a file rather then a directory. These are necessary when using directory names that contain spaces or other characters.)
 
Thanks for responding!

Sorry for not answering,

So instead of exporting say "C:\Image\Image.jpg" as the text to word, I just export "<file://\\C:\Image\Image.jpg>" to word and when the word document is loaded, it will replace the text with the image?

Thanks,

Alex
 
The text is not being replaced by the actual image when I use <file://\\C:\Image\Image.jpg>.

If somebody could help me, I would really appreciate it!


Thanks,

Alex

 
You may try something like this:
objWord.Selection.InlineShapes.AddPicture _
FileName:="C:\Image\Image.jpg" _
, LinkToFile:=True, SaveWithDocument:=True

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
So would I copy the code to word and the text will be replaced with the image that it is linking?
 
How are you writing to word from access ?
I assumed by automation with an object I guessed objWord.
Please post what you have so far to help us help you.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I am doing this by using an unorthodox way. This is the only way that I have got it to export multiple items to the same word document.

I have a form which contains the following fields:

Item ID (Autonumber)
Item Text (Memo)
Item Key (Text)
Case Text (Memo)
Graphic (Hyperlink)
Unique Item Identifier (Text)
Blank Memo Box
Drop-Down Menu (lists Unique Item Identifers for the users to select and pulls up the item that contains the selected Unique Item Identifier)


There are Four Command Buttons on this form:

Find Item
Add to Test
Export Test
Clear Test


The user can either find the item by using the Command Button "Find Item" or by using the Drop-Down Menu.

Once the user has found the item that they want to be added to the test, they click "Add to Test" Command Button, and the Item Text, Case Text, Item Key and Graphic Hyperlink are all copied to the Empty Memo Box.

The user can add as many items as they want by repeating the above steps (All of the Items' Item Texts, Case Texts, Item Keys, and Graphic Hyperlinks are added to the same memo box). Once the user has selected all of the items they want to appear on the test, they click "Export Test" Command Button and the text that is in the empty memo box is exported to a word template which has the bookmark "Questions."

The reason why I am doing it this way is because this is the only method that I have found to work that allows the user to export more than one item to the same word document.

Is there a better and easier way to go about doing this?

Thanks,

Alex

 
Is it something that you have to change in word that will replace the hyperlink automatically?
 
How are you writing to word from access ?
As far as you don't answer my question, I can't explain you how to incorporate this snippet:
objWord.Selection.InlineShapes.AddPicture _
FileName:="C:\Image\Image.jpg" _
, LinkToFile:=True, SaveWithDocument:=True

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Oh, sorry.

Here's the code that I'm using:

Code:
Private Sub Command48_Click()
   Dim WordApp As Word.Application
   Dim strTemplateLocation As String
  
   strTemplateLocation = "C:\Test.dot"
    
    
   On Error Resume Next
   Set WordApp = GetObject(, "Word.Application")
   If Err.Number <> 0 Then
     Set WordApp = CreateObject("Word.Application")
   End If
   On Error GoTo ErrHandler
   
   
   WordApp.Visible = True
   WordApp.WindowState = wdWindowStateMaximize
   WordApp.Documents.Add Template:=strTemplateLocation, NewTemplate:=False
    
   With WordApp.Selection
   
    .GoTo what:=wdGoToBookmark, Name:="Questions"
    .TypeText [Text50]
    
    .GoTo what:=wdGoToBookmark, Name:="Answers"
    .TypeText [Text63]

   End With
    
   DoEvents
   WordApp.Activate
    
   Set WordApp = Nothing
   Exit Sub


ErrHandler:
Set WordApp = Nothing
End Sub

Text50 is the memo box that everything has been copied to (Item Text, Case Text, and Graphic Hyperlink).

Text63 is the memo box that all of the item keys have been copied to.

This is done to separate the item questions from the actual answers.


Alex
 
Try something like this:
.GoTo what:=wdGoToBookmark, Name:="Questions"
.TypeText [Text50]
[blue].InlineShapes.AddPicture FileName:="C:\Image\Image.jpg" _
, LinkToFile:=True, SaveWithDocument:=True[/blue]

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

That will not work since all of the item cases, graphic hyperlinks, and item texts are in Text50 and I want the image to go between case text and item text.

Here's an example of the output:

Case Text for Item 1 Case Text for Item 1Case Text for Item 1 Case Text for Item 1 Case Text for Item 1 Case Text for Item 1 Case Text for Item 1 Case Text for Item 1 Case Text for Item 1.

<file://\\C:\Image\Image.jpg>

Item 1 Text Item 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 TextItem 1 Text.


This is all in Text50.

The <file://\\C:\Image\Image.jpg> needs to be replaced with the actual iamge.jpg, the actual picture.

Thanks,

Alex
 
And what about something like this ?
.GoTo what:=wdGoToBookmark, Name:="Questions"
.TypeText [Case Text]
.InlineShapes.AddPicture FileName:=[Graphic].Hyperlink.Address _
, LinkToFile:=True, SaveWithDocument:=True
.TypeText [Item Text]
You may have to play with vbCrLf after [Case Text] and/or before [Item Text].

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
If I'm not mistaken, this method will only add one item to the word document. Do I have to change the bookmarks in Word to allow the addition of multiple items this way?

Thanks,
Alex
 
How was Text50 populated ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Items are added to Text50 using the following code:

Code:
Me.Text50.SetFocus
Me.Text50 = Me.CaseText & vbCrLf & vbCrLf & Me.Text66 & Me.Text68 & " " & Me.ItemText & vbCrLf & vbCrLf & Me.Text92 & Me.Graphic & Me.Text94 & vbCrLf & vbCrLf & Me.Item_Answers
Me.Refresh
Me.Refresh

The Text66's, 68's, etc. are used for the numbering and to show which items have a graphic.

Alex
 
Is there a way to code the bookmarks in word that will allow the addition of multiple items to the same word document?

Maybe something along the lines of bookmark.NEXT?

P.S.- Is there a good reference to a mail merge tutorial?

Thanks,
Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top