views:

179

answers:

2

Trying to find the object property for Access to get the default file location so I can script an update to it. Example: this grabs the stuff from Word and tells me where the user file, and template paths point

Const wdDocumentsPath = 0
Const wdWorkgroupTemplatesPath = 3
Set objWord = CreateObject("Word.Application")
Set objOptions = objWord.Options
Wscript.Echo "Word Documents Path: " & _
    objOptions.DefaultFilePath(wdDocumentsPath)
Wscript.Echo "Word Workgroup Templates Path: " & _
    objOptions.DefaultFilePath(wdWorkgroupTemplatesPath)
objWord.Quit

Trying to do something similar with Access.

A: 

Hmmm ... just having a quick look through the C:\Program Files\Microsoft Office\Office10\MSACC.OLB (I'm using an older Access) using TLViewer.

Property Path As String [Get/o]
  member of Access.CodeProject

Property Path As String [Get/o]
  member of Access.CurrentProject

Property FullPath As String [Get/o]
  member of Access.Reference

I have no idea whether these are useful or not -- I'm not in Access much.

boost
Boost just so you know, those properties return the path and path+filename of the currently opened database.
Oorang
Ok, thanks for the heads-up.
boost
A: 

There are two ways to do this. You can, as you suggested, get the Access Object and work with it:

Dim objAcc     
Set objAcc = CreateObject("Access.Application")
objAcc.SetOption "Default Database Directory", "C:\Test"
objAcc.Quit

Or you can just edit the value in the registry:

Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")    
WshShell.RegWrite  "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Access\Settings\Default Database Directory", "C:\Test", "REG_SZ"
Oorang