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
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