Exporting Hyperlink to Word

infinitx

Registered User.
Local time
Today, 06:52
Joined
Mar 22, 2004
Messages
63
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: "<file://\\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?

I am doing the exporting 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.

Here's the code that I'm using to export to word:


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.

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
 

Users who are viewing this thread

Back
Top Bottom