Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a word Document

Status
Not open for further replies.

darinmc

Technical User
Feb 27, 2005
171
GB
Hi
I'm not sure if this is the right forum.
The code below is in a command button which opens a word doc to a specific employees registration Number.
This works fine (if the document already exists) BUT how would i be able (check that a doc exists 1st) to open a NEW Word document if 1 does not exist? (I would assume an if statement would be required?)

It would then be better to go 1 step further and create a new document if required with the name = EmpregNbr.

Hope you are able to help
Thx
Darin



Code:
Private Sub cmdOpenWord_Click()
Dim stAppName As String
Dim stPathA As String
Dim stPathB As String
Dim stPathC As String
Dim stCombinedPath As String
Dim EmpRegNbr As Integer

EmpRegNbr = Me.EmpRegNo

stPathA = SysCmd(acSysCmdAccessDir)
stAppName = "WINWORD.EXE "
stPathB = "\\Darin\LynxDatabase\EmpWord\" '"c:\1\"
stPathC = ".doc"
stCombinedPath = stPathA & stAppName & stPathB & EmpRegNbr & stPathC
Call Shell(stCombinedPath, 1)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top