Results 1 to 11 of 11
  1. #1
    Join Date
    May 2004
    Posts
    37

    Question Unanswered: Exporting Hyperlink to Word

    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

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Okay I know what you are talking about... There is a way to do it. I just have to go back a bit and do some digging.

    This is the code in MS Word needed...

    { Includepicture “C:\\image\\image.jpg” \d }

    The way you get that code is... You create that IncludePicture Field in your document and set the path area as the bookmark.

    Goto Insert>Field... Scroll down to IncludePicture.

    Hope this helps. Let me know if I can help in any other way.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    May 2004
    Posts
    37
    Hi JSThePatriot,

    Thanks for responding!

    Is there any way to do this through coding?

    This worked when I did it manually:

    { Includepicture “C:\image\\image.jpg” \d } however since the hyperlink address is in the same Text Box as the Item Text and Case Text, the whole Text Box (hyperlink included) is exported and replaces the same bookmark "Questions."

    Am I going about this the wrong way?

    In other words, is there a way to create bookmarks in word which allows the user to export multiple items to the same word document. Maybe something like Bookmark.NEXT?

    Thanks again,
    Alex

  4. #4
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Ah... now that I dont know. Experiment around with it and search through google and the forums. Wish I could help more . If you find the answer please post it so everyone can learn.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  5. #5
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    There is a NEXT field code. You may want to try that and see what happens (it is used for mailmerge). You may want to create a mail merge through access... that may work better because that will definitely do what you are wanting.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  6. #6
    Join Date
    May 2004
    Posts
    37
    I have tried to follow a tutorial on how to use mail merge but I seem to be doing something wrong.

    Could you explain to me on how to do it or reference me to a place that will show me how to do it?

    I would really appreciate it,
    Alex

  7. #7
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    I can give you code on how to make access open word up, but I havent quite figured out the mail-merge thing. I normally run the mail merge wizard and just import from my database . Grr... hehe wish I could help more, as I wish I knew how to do that.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  8. #8
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Code:
    Private Function openWDPrice()
    
        On Error GoTo openWD_err
    Dim path As String
    
        path = "J:\FullPriceSheet.doc"
        Set WDapp = New Word.Application
        WDapp.Visible = True
        WDapp.Documents.Open (path)
        
        Set WDapp = Nothing
        Set WDdoc = Nothing
    
    openWD_exit:
        Exit Function
        
    openWD_err:
        MsgBox Err.Description
        Resume openWD_exit
        
    End Function
    The above code is what I use to open word. Hope that might help somthing.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  9. #9
    Join Date
    May 2004
    Posts
    37
    I know how to open word from access, but I just can't figure out how to use mail merge either.

    Thanks for the help, I'll play around with INCLUDEPICTURE and mail merge and if I find anything worthwhile, I'll post it.

    Alex

  10. #10
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    If I find anything between now and then I will as well post... sorry I couldnt help you more.

    Could you post the 'tutorial' that was telling you how to do it? I may be able to see something you didnt or figure out something just by messing around with it.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  11. #11
    Join Date
    May 2004
    Posts
    37
    Here's how i've been told to use mail merge:

    In word, go to insert | bookmark. Create a bookmark this way, and in Access, use the following code in the Command Button's OnClick Event:

    Private Sub Command48_Click()
    ' Check for empty fields and unsaved record.
    If IsNull(TextFromAccess) Then
    MsgBox "Field cannot be empty"
    Me.TextFromAccess.SetFocus
    Exit Sub
    End If

    ' Create a Word document from template.
    Dim WordApp As Word.Application
    Dim strTemplateLocation As String

    ' Specify location of template
    strTemplateLocation = "C:\Merge.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

    ' Replace each bookmark with field contents.
    With WordApp.Selection


    .Goto what:=wdGoToBookmark, Name:="Bookmark"
    .TypeText [TextFromAccess]

    End With

    DoEvents
    WordApp.Activate

    Set WordApp = Nothing
    Exit Sub

    ErrHandler:
    Set WordApp = Nothing
    End Sub


    See if that is something that you might be able to use.

    Alex

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •