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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word default directory 3

Status
Not open for further replies.

cyberbob999

Technical User
Jun 26, 2003
23
US
Let's say that the directory where my db is located is c:\a\b\c\d\. Is there any way to use objword.documents.open() such that I can just put the include the filename as the argument vice the entire path? (i.e. objword.documents.open(filename) vice objword.documents.open(c:\a\b\c\d\filename)) More specifically, I need to be able to do this without knowing the exact path for the db. So, I guess my real question is, can I somehow set the default directory for MSWord documents to the same directory as my current db without knowing what the path is?

Thanks

Michael Austin
 
Hi Michael

You can "extract" the path to your current db by using its "Name" property:
Code:
Dim ThePath As String, x As Integer
ThePath = CurrentDb.Name
...
x = InStr(1, StrReverse(ThePath), "\")
ThePath = Left(ThePath, Len(ThePath) - x + 1)


Then you can use
objword.documents.open(ThePath & filename) to open the doc.

Regards,
MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Hi cyberbob999,

You cannot give Word an implicit directory; one way or another you have to tell it what the directory is, so you must find out from Access. There isn't a path property so you must strip the path from the Name ..

Code:
MyPath = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\") - 1)

.. then you can do ..

Code:
objWord.Documents.Open(MyPath & "\" & Filename)


Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Very useful guys, thanks! That is exactly what I was looking for!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top