By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,154 Members | 2,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,154 IT Pros & Developers. It's quick & easy.

Open a file specified in a field using Shell function

lwwhite
P: 16
I'm working with VB in an Access 2003 database. I have a form, called "EditWindowsFields," 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\FrameMaker7.1\FrameMaker.exe C:\Sourcedocs\Me.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?
Dec 1 '06 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,616
I'm working with VB in an Access 2003 database. I have a form, called "EditWindowsFields," 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\FrameMaker7.1\FrameMaker.exe C:\Sourcedocs\Me.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?
Expand|Select|Wrap|Line Numbers
  1. Shell "C:\Program Files\Adobe\FrameMaker7.1\FrameMaker.exe C:\Sourcedocs\" & Me.sourcedoc, vbNormalFocus
That should do it for you.
Dec 1 '06 #2

ADezii
Expert 5K+
P: 8,669
I'm working with VB in an Access 2003 database. I have a form, called "EditWindowsFields," 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\FrameMaker7.1\FrameMaker.exe C:\Sourcedocs\Me.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:
Expand|Select|Wrap|Line Numbers
  1. Dim RetVal
  2. RetVal = Shell("C:\WINDOWS\Regedit.exe", vbNormalFocus)
Dec 1 '06 #3

NeoPa
Expert Mod 15k+
P: 31,616
'Just remember that when using the Shell() function, that it returns a Variant
'(Double), thus you must use this syntax:
Expand|Select|Wrap|Line Numbers
  1. Dim RetVal
  2. RetVal = Shell("C:\WINDOWS\Regedit.exe", vbNormalFocus)
Although that is certainly recommended (or use
Expand|Select|Wrap|Line Numbers
  1. 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.
Dec 1 '06 #4

lwwhite
P: 16
Expand|Select|Wrap|Line Numbers
  1. 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!
Dec 1 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.