Please Help?! Shell Command

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys,
I would really appreciate your help with this one. I open hyperlinks from a
command button in access that opens Word Documents, I would like to open
these documents using Word Viewer (so that they can't be editted!!!). I have
been told that the shell command is the way forward but I don't know where to
start. Please Help.
Cheers
 
You would only be able to do this if you could guarantee that all of your
users will have the Word viewer installed, and you know where the executable
exists.

You'd have to build a string along the lines of

"<full path to Word viewer executable>" "<full path to document to be
opened>"

and pass that string to the Shell function.
 
Excellent Doug,
could you give me an example or point me in the direction of one please??
Cheers
--
Regards

Ashley Smart


Douglas J Steele said:
You would only be able to do this if you could guarantee that all of your
users will have the Word viewer installed, and you know where the executable
exists.

You'd have to build a string along the lines of

"<full path to Word viewer executable>" "<full path to document to be
opened>"

and pass that string to the Shell function.
 
An example of what? How to use the Shell command?

I don't know the name of the actual Word Viewer, so I can't give you an
example specific to that, but if you wanted to use Notepad to open a text
file named Sample.txt, stored in C:\Temp, you could use code like:

Dim strShell As String

strShell = """C:\Windows\Notepad.exe"" ""C:\Temp\Sample.txt"""
Shell strShell, vbNormalFocus

Note that I've put double quotes around both the path to Notepad.exe and the
text file: they're not actually required in this case, but they are when the
path contains blanks.

See http://msdn.microsoft.com/library/en-us/vbenlr98/html/vafctShell.asp and
http://msdn.microsoft.com/library/en-us/vbenlr98/html/vafctshellx.asp for
more details


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


A. Smart said:
Excellent Doug,
could you give me an example or point me in the direction of one please??
Cheers
 
Ok thats a good start.
Problem is that my Word Documents Path changes, as I have documents linked
to each individual record in the database.
For Example:

"\\Mercury\Users\AshleyS\Trim Line\" & Me.Work_Station & "\" &
Me.Work_Instruction
Work_Station and Work_Instruction are field names.
At the moment I am opening the documents using hyperlinks.

Hope that makes sense!!
 
Sounds as though you'd need something like:

strShell = """C:\Windows\Notepad.exe"" " & _
""""\\Mercury\Users\AshleyS\Trim Line\" & _
Me.Work_Station & "\" & Me.Work_Instruction & """"

(where obviously you need to replace C:\Windows\Notepad.exe with whatever's
appropriate)
 
Back
Top