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
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>