Open word doc from the CURRENT directory in Access w/o full path

..without giving the full path name

H i,
 I need to keep a DB application portable so I do not want to hard code  the path name of the word documents that I open from a form.
Is there anyway to make it  look for the document in the directory of where ever the the DB is currrently installed?

currently i use this:

Dim WordApp As Word.Application
Dim WordDocument As Word.Document
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Open ("C:\temp\mydoc.doc")
WordApp.Visible = True

thx
kmittalAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
HobsonTConnect With a Mentor Commented:
I use the following to return the path of the current database:
Public Function FilePath() As String
  Dim TempPath As String
  TempPath = CurrentDb.Name
  Do Until Right$(TempPath, 1) = "\"
    TempPath = Left$(TempPath, Len(TempPath) - 1)
  Loop
  FilePath = TempPath
End Function

To use this in your code:
Dim WordApp As Word.Application
Dim WordDocument As Word.Document
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Open (FilePath & "mydoc.doc")
WordApp.Visible = True

Hope this helps

Trevor
0
 
kmittalAuthor Commented:
Thanks a lot Trevor, exactly what I needed!
0
All Courses

From novice to tech pro — start learning today.