Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

Settine the DB path within the DOT template

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel Caron - 05 Apr 2005 18:09 GMT
Good Day to all.

Coming from the VB6 world, I am being confronted with a dilemna here.

When running my template from within the VBA IDE, there is no problem at all
to open my database like this

Set dbPars = OpenDatabase(ActiveDocument.Path & "\" & "pars.mdb")
Set rsPars = dbPars.OpenRecordset("PARS").

But the DB is in another directory on my HD. I need to know to code the path
of my DB so it can be anywhere on my HD.

And also I need to know where in the DOT I should put that code, in a module
? in the Userform_Initialize ? I want to make sure that it will get loaded
flawlessly when opening the DOT file.

Regards to all

Daniel
Perry - 05 Apr 2005 18:19 GMT
Store the pathname in a intermediaire file, such as an INI file.
Pseudo code to retrieve the DB path from Word VBA:

Snippet of file: c:\Temp\MyIniFile.INI
=start snip
[Database]
Path=y:\Data\Anypath\
Name=MyDatabase.MDB
=end snip

Retrieving info in Word:
=start Word VBA code
Dim sINI as string
Dim sPath as string
Dim sDBName as string
sINI = "c:\Temp\MyIniFile.INI"
sPath = System.PrivateProfilestring(sINI, "Database", "Path")
sDBName = System.PrivateProfilestring(sINI, "Database", "Name")
MsgBox "My database path is: " sPath & vbCr & _
   "FileName: " &  sDBName & vbCr & "DB FullFileName: " & vbCr & _
   sPath & sDBName

=end Word VBA code

Krgrds,
Perry

> Good Day to all.
>
[quoted text clipped - 16 lines]
>
> Daniel
Daniel Caron - 05 Apr 2005 18:46 GMT
Thank You once again Perry for your help. It's an alternative. I though that
you could say something like app.path. In VB6 it is easy.

Regards

> Store the pathname in a intermediaire file, such as an INI file.
> Pseudo code to retrieve the DB path from Word VBA:
[quoted text clipped - 47 lines]
>>
>> Daniel
Daniel Caron - 05 Apr 2005 19:03 GMT
Thanks..it did the trick.

Daniel

Gossh...I love this newsgroup.

> Store the pathname in a intermediaire file, such as an INI file.
> Pseudo code to retrieve the DB path from Word VBA:
[quoted text clipped - 47 lines]
>>
>> Daniel
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.