avoiding hard coding current directory file path

KirRoyale

Registered User.
Local time
Today, 22:03
Joined
Apr 22, 2013
Messages
61
I have a piece of code to open a Word document. I would like to use the ‘current project.path’ instead of hard coding the directory path but cannot seem to get the right code / syntax.

Private Sub OpenWordDocument_Click()
Dim oApp As Object
Dim strDocName As String
strDocName = "C:/Documents/Instructions.docx"
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
oApp.Documents.Open strDocName
End Sub

Could somebody please help?
 
strDocName = CurrentProject.Path & "\" & somefilename

Note that Microsoft uses backslashes.
 
Thank you - that works.
 

Users who are viewing this thread

Back
Top Bottom