Prompting a user for input

  • Thread starter Thread starter Jasper Recto
  • Start date Start date
J

Jasper Recto

Is it possible to create a prompt in Word that would ask a user for a file
name and then open the word document the user just asked for?

Thanks,
Jasper
 
This will be a Kiosk on the shop floor. I can not have users searching for
a file name. I need a prompt for them to access the correct file.
 
Graham,

That worked great!! One more question though. Is it possible to be able to
search for the file the user just entered. What the user will do is enter a
part number (eg. 12268700). This part number will be the name of the file
they want to open. This file will be under a folder of the same name with a
'PN' in front of it (eg. PN 12268700). Can I use the input value to define
the path statement also?

Thanks for everything!!!

Jasper
 
Let me get this right.
For file 12268700
the path will be
\path\PN 12268700\12268700.doc ?
That should not be too difficult. Try the following variation.

The file open string is set at:

Documents.Open FileName:=MyPath & "PN " & MyValue & _
"\" & MyValue & ".doc"

This comprises MyPath = C:\My Documents\ (which you can set against the
string definition)

& PN
which gives
C:\My Documents\PN

I have assumed a space after PN

& MyValue - which is the input part number 12268700 which gives
C:\My Documents\PN 12268700

& "\"
which gives
C:\My Documents\PN 12268700\

& MyValue
which gives
C:\My Documents\PN 12268700\12268700

& ".doc"
which completes the path as
C:\My Documents\PN 12268700\12268700.doc

With this in mind you should be able to set this to match the required
document path


Sub PromptForFile()

Dim Title As String
Dim Default As String
Dim MyValue As Variant
Dim MyText As String
Dim MyPath As String

Title = "File Open"
Default = ""
MyText = "Enter Part Number in the format" & vbCr & _
"12345678"

MyPath = "C:\My Documents\"

GetInput:
MyValue = InputBox(MyText, Title, Default)
If MyValue = "" Then
End 'quit subroutine
End If
On Error GoTo Oops 'just in case
Documents.Open FileName:=MyPath & "PN " & MyValue & _
"\" & MyValue & ".doc"
End 'End subroutine

Oops:

End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.dsl.pipex.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
THANK YOU!!!!!
THAT WORKED PERFECT!!!

Graham Mayor said:
Let me get this right.
For file 12268700
the path will be
\path\PN 12268700\12268700.doc ?
That should not be too difficult. Try the following variation.

The file open string is set at:

Documents.Open FileName:=MyPath & "PN " & MyValue & _
"\" & MyValue & ".doc"

This comprises MyPath = C:\My Documents\ (which you can set against the
string definition)

& PN
which gives
C:\My Documents\PN

I have assumed a space after PN

& MyValue - which is the input part number 12268700 which gives
C:\My Documents\PN 12268700

& "\"
which gives
C:\My Documents\PN 12268700\

& MyValue
which gives
C:\My Documents\PN 12268700\12268700

& ".doc"
which completes the path as
C:\My Documents\PN 12268700\12268700.doc

With this in mind you should be able to set this to match the required
document path


Sub PromptForFile()

Dim Title As String
Dim Default As String
Dim MyValue As Variant
Dim MyText As String
Dim MyPath As String

Title = "File Open"
Default = ""
MyText = "Enter Part Number in the format" & vbCr & _
"12345678"

MyPath = "C:\My Documents\"

GetInput:
MyValue = InputBox(MyText, Title, Default)
If MyValue = "" Then
End 'quit subroutine
End If
On Error GoTo Oops 'just in case
Documents.Open FileName:=MyPath & "PN " & MyValue & _
"\" & MyValue & ".doc"
End 'End subroutine

Oops:

End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.dsl.pipex.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
Back
Top