Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,877
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Best Way to Open Hyperlink Fields? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I have a continous sub form that has a bound hypAttachment field (hyperlink) that contains the following entries:

    F:AppsAccess2kapplication.pdf
    F:AppsAccess2kFORLOGO.GIF
    F:AppsAccess2kJetComp.doc
    F:AppsAccess2kJetUtils.exe
    F:AppsAccess2kShaw04.xls

    When I click on the *.pdf & *.gif the file is opened and when I close the file I return back to the Subform

    When I click on the *.doc the file is opened and when I close the file I return to Windows Desktop
    How can I return to Subform when I close a Word Doc?

    When I click on the *.xls the nothing opens.
    How should open Excel fiels?

    Thanks, John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Best Way to Open Hyperlink Fields? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Following a hyperlink is not governed by Access but by Windows. I doubt you can do much about the behavior of .doc files.

    About .xls files: can you open .xls files from Windows Explorer when Excel is not active?

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,877
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Best Way to Open Hyperlink Fields? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    What would the code be to strip the leading and trailing from the following text box string?

    #F:AppsAccess2kJetComp.doc#

    Thanks, John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Best Way to Open Hyperlink Fields? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You'd use the expression
    <code>Mid([NameOfTextBox], 2, Len([NameOfTextBox]) - 2)</code>
    or
    <code>Replace([NameOfTextBox], "#", "")</code>
    It's not clear to me whether you want to update the value of the text box or just retrieve the value without the # characters.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,877
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Best Way to Open Hyperlink Fields? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Hans

    Thanks for the code

    I

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Best Way to Open Hyperlink Fields? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    If you don't want to use a hyperlink field, you can use a text field to store file paths+names, and use Application.FollowHyperlink or the API function ShellExecute with the Open argument; see for example <post#=320106>post 320106</post#>.

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,877
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Best Way to Open Hyperlink Fields? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    The following opens excel file OK, however, when I close excel, control does not come back to my subform where i initiated the initial open attachment from.

    <pre>Public Sub OpenExcelDocShellExecute(strFilePath As String)

    lngResult = ShellExecute(hWndAccessApp, "Open", _
    strFilePath, 0&, 0&, SW_SHOWMAXIMIZED)

    If lngResult <= 32 Then
    MsgBox "Couldn't open workbook.", vbExclamation
    End If

    End Sub
    </pre>



    How can I get the focus come back to my subform?

    I was having same problems with Word documents and fixed it with the following:

    When I close the word document focus returns to my subform which is what I want

    <pre>Public Sub OpenWordDoc(strFilePath As String)

    Dim appWord As Word.Application
    Dim doc As Word.Document
    Set appWord = New Word.Application
    Set doc = appWord.Documents.Open(strFilePath)
    appWord.Visible = True
    appWord.Activate
    Set appWord = Nothing
    Set doc = Nothing

    End Sub
    </pre>


    Thanks, John

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Best Way to Open Hyperlink Fields? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Sorry, no idea. It works the way you want for me in Access 2002. Perhaps someone with Access 2000 can help.

Posting Permissions

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