Open Document

R

Rich S

Hi, I am trying to create a macro that will open a
document - it needs to prompt the user for a filename (we
use numbers), plus there are 4 "0's in front of each
filename and I don't want them to have to type this. So
far I have:

Documents.Open FileName:="J:/WillForm/0000-this is where I
need a user prompt"

Any help is appreciated!
 
J

Jezebel

Least effort is to use an input box.

Dim pName as string
pName = InputBox("Enter filename")
If len(pName) > 0 then
Documents.Open FileName:="J:/WillForm/0000" & pName
End if

You should allow for the user to cancel the input, and also deal with the
inevitability that they'll sometimes get the name wrong. Why not just use
the ordinary fileopen and let them select the file? ... then they don't have
to type anything at all, and can't get it wrong.
 

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

Top