Problem with Call Shell


L

Leslie Isaacs

Hello All

This works:

Dim stAppName As String
stAppName = "C:\Program Files\Microsoft Office\Office\WINWORD.EXE
C:\pay\Let\exampleletter.doc"
Call Shell(stAppName, 1)

but if I replace the stAppName assignment with :
stAppName = "C:\Program Files\Microsoft Office\Office\excel.EXE C:\Documents
and Settings\les\My Documents\statement 548786.xls"
.... it doesn't work.

It seems that this command doesn't like the spaces in the file pathname or
in the filename (spaces in the pathname to the .exe file are OK, judging by
the fact that the first e.g. above works).

I have tried quotes around the file pathname and/or in the filename, but no
joy.

Any suggestions?
Thanks for any help.
Leslie Isaacs
 
Ad

Advertisements

D

Douglas J. Steele

Actually, I'm surprised that the first one works.

Try:

stAppName = """C:\Program Files\Microsoft Office\Office\excel.EXE"" " & _
"""C:\Documents and Settings\les\My Documents\statement 548786.xls"""

although easier would be to use Application.FollowHyperlink, rather than
Shell:

Application.FollowHyperlink "C:\pay\Let\exampleletter.doc"
Application.FollowHyperlink "C:\Documents and Settings\les\My
Documents\statement 548786.xls"
 
L

Leslie Isaacs

Hello Douglas

That's great - the FollowHyperlink worked brilliantly!
I had tried FollowHyperlink before but must have got the syntax wrong.
I got the Call Shell code by using the create new button wizard and
selecting the runApplication wizard.

Anyways, many thanks again.
Les
 
P

PayeDoc

Douglas

Having said that I had got the Application.FollowHyperlink command to work, this was in fact on my PC at home. Unfortunately when I try it at work (which is where the problem is) it doesn't work!!

I think I have discovered that the problem is to do with the file I want to open being on the fileserver (called Server), in a directory (called payedoc programmes) which is mapped to the workstations as the Z drive. While this works fine (at work):

Application.FollowHyperlink "C:\payedoc programmes\GP reg Pay Circular 2009-10.pdf"

this does not (nothing happens when the button with this OnClick event is clicked):
Application.FollowHyperlink "Z:\GP reg Pay Circular 2009-10.pdf"

and neither does this:
Application.FollowHyperlink "\\Server\payedoc programmes\GP reg Pay Circular 2009-10.pdf"

So how do I get Application.FollowHyperlink with a file on the network?
And why can't this be simple?!

Thanks for your continued help.
Les
 
D

Douglas J. Steele

I just did a test, and had no problem using either a mapped drive or a UNC.

You might have to check with your network administrator to see whether any
policies have been set that could be contributing to the problem you're
seeing.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Douglas

Having said that I had got the Application.FollowHyperlink command to work,
this was in fact on my PC at home. Unfortunately when I try it at work
(which is where the problem is) it doesn't work!!

I think I have discovered that the problem is to do with the file I want to
open being on the fileserver (called Server), in a directory (called payedoc
programmes) which is mapped to the workstations as the Z drive. While this
works fine (at work):

Application.FollowHyperlink "C:\payedoc programmes\GP reg Pay Circular
2009-10.pdf"

this does not (nothing happens when the button with this OnClick event is
clicked):
Application.FollowHyperlink "Z:\GP reg Pay Circular 2009-10.pdf"

and neither does this:
Application.FollowHyperlink "\\Server\payedoc programmes\GP reg Pay Circular
2009-10.pdf"

So how do I get Application.FollowHyperlink with a file on the network?
And why can't this be simple?!

Thanks for your continued help.
Les
 
P

PayeDoc

Douglas

Unfortunately I am the nearest thing we have to a network administrator -
and I've put no such restrictions in place!
We can open files on the Z drive from windows explorer on any of the
workstations without a problem. If there was a policies issue, presumably
this wouldn't be the case?

Thanks for any further suggestions (have you have one!).
Les
 
Ad

Advertisements

D

Douglas J. Steele

Does the Dir function work properly for either means of checking?

In other words, do both Dir("Z:\GP reg Pay Circular 2009-10.pdf") and
Dir("\\Server\payedoc programmes\GP reg Pay Circular 2009-10.pdf") return GP
reg Pay Circular 2009-10.pdf?
 
P

PayeDoc

Douglas

Yes - both these do return:
GP reg Pay Circular 2009-10.pdf

What does that mean?
Les
 
P

PayeDoc

Hello Douglas

Thanks for your further reply.
In fact I already have all the code at
http://www.mvps.org/access/api/api0018.htm in a module (you may have noticed
my post from 20 Aug with subject "How to open a pdf file" in this
newsgroup: this was in relation to the same problem - and now the two
threads seem to have converged!), but am not sure how to test it as you
suggest.

I really am grateful for this help.
Les
 
Ad

Advertisements

Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top