How to get database name and location in VBA

K

Keith Reilly

I made a form in VBA that will open microsoft word start a mail merge
and give it a certian table. the only problem is in my code i have to
write in the location and name of the database. what i want is a dynamic
variable so i can check what the name of the database is and where then
give that to microsoft word. right now if the name changes or its moved
this form is broken. here is the code that needs the variable

objWord.MailMerge.OpenDataSource _
Name:="C:\Program Files\School Database\" & _
"RyeNursery.mdb", _
LinkToSource:=True

so i want

objWord.MailMerge.OpenDataSource _
Name:= strPath & _
strDatabaseName, _
LinkToSource:=True

how do i get the path and database name? is this possible? any help is
appreciated
 
L

Larry Linson

Open any Module, View the Immediate Window, type in "? CurrentDB.Name"
without the quote marks and see if that doesn't return what you are looking
for.

Larry
 
N

Nick Coe \(UK\)

I think you need to look at CurrentProject.FullName in the
Help. Although, IIRC, the help implies it's more relevant
to adp's it will also return the fully qualified name for
the current mdb I think.

Also relevant may be CodeProject.

--
Nick Coe (UK)
http://www.alphacos.co.uk/




In Keith Reilly typed:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top