Open a file specified in a field using Shell function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lwwhite
    New Member
    • Dec 2006
    • 16

    #1

    Open a file specified in a field using Shell function

    I'm working with VB in an Access 2003 database. I have a form, called "EditWindowsFie lds," that contains a field called "sourcedoc. " I am trying to use the Shell function to open the XML file that is specified in the "sourcedoc" field. I've created a button on the form with this as the OnClick event:

    Shell "C:\Program Files\Adobe\Fra meMaker7.1\Fram eMaker.exe C:\Sourcedocs\M e.sourcedoc", vbNormalFocus

    Needless to say, that's not working and I can't figure out how to call a file specified in a field rather than a hardcoded file name in this function. I'm not a programmer at all, just muddling my way through here. Can anyone help?
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Originally posted by lwwhite
    I'm working with VB in an Access 2003 database. I have a form, called "EditWindowsFie lds," that contains a field called "sourcedoc. " I am trying to use the Shell function to open the XML file that is specified in the "sourcedoc" field. I've created a button on the form with this as the OnClick event:

    Shell "C:\Program Files\Adobe\Fra meMaker7.1\Fram eMaker.exe C:\Sourcedocs\M e.sourcedoc", vbNormalFocus

    Needless to say, that's not working and I can't figure out how to call a file specified in a field rather than a hardcoded file name in this function. I'm not a programmer at all, just muddling my way through here. Can anyone help?
    Code:
    Shell "C:\Program Files\Adobe\FrameMaker7.1\FrameMaker.exe C:\Sourcedocs\" & Me.sourcedoc, vbNormalFocus
    That should do it for you.

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by lwwhite
      I'm working with VB in an Access 2003 database. I have a form, called "EditWindowsFie lds," that contains a field called "sourcedoc. " I am trying to use the Shell function to open the XML file that is specified in the "sourcedoc" field. I've created a button on the form with this as the OnClick event:

      Shell "C:\Program Files\Adobe\Fra meMaker7.1\Fram eMaker.exe C:\Sourcedocs\M e.sourcedoc", vbNormalFocus

      Needless to say, that's not working and I can't figure out how to call a file specified in a field rather than a hardcoded file name in this function. I'm not a programmer at all, just muddling my way through here. Can anyone help?
      'Just remember that when using the Shell() function, that it returns a Variant
      '(Double), thus you must use this syntax:
      Code:
      Dim RetVal
      RetVal = Shell("C:\WINDOWS\Regedit.exe", vbNormalFocus)

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Originally posted by ADezii
        'Just remember that when using the Shell() function, that it returns a Variant
        '(Double), thus you must use this syntax:
        Code:
        Dim RetVal
        RetVal = Shell("C:\WINDOWS\Regedit.exe", vbNormalFocus)
        Although that is certainly recommended (or use
        Code:
        Call Shell("C:\WINDOWS\Regedit.exe", vbNormalFocus)
        ), it is not actually necessary due to Access's propensity to be very (overly) forgiving in matters of code.
        You can take it as a strong recommendation though, to use code which illustrates to any reader that it is a function rather than a simple subroutine procedure you're calling.

        Comment

        • lwwhite
          New Member
          • Dec 2006
          • 16

          #5
          Originally posted by NeoPa
          Code:
          Shell "C:\Program Files\Adobe\FrameMaker7.1\FrameMaker.exe C:\Sourcedocs\" & Me.sourcedoc, vbNormalFocus
          That should do it for you.
          Perfect! Thank you so much!

          Comment

          Working...