I need VBA assistance to set a directory in Access module

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good afternoon,

I need a VBA command that will set the current directory in Access to a
specific folder, so that even if I change the current directory by opening a
file from a different directory, when the sub runs, the directory will be set
to specific folder when I use the show command for the open dialogue box.

This is my code, but for some reason doesn't open the proper directory and
only opens whatever the last directory opened in the application.
Dim OBJ As Object
Set OBJ = GetObject(, "EXCEL.APPLICATION")
Dim SPATh As String
OBJ.Visible = True
SPATh = "C:\SCR DATABASE\CURRENT YEAR Data And Charts\SCR\SCR SUMMARY"
ChDrive SPATh
ChDir SPATh
OBJ.Application.Dialogs(xlDialogOpen).Show
 
Brent E said:
Good afternoon,

I need a VBA command that will set the current directory in Access to
a specific folder, so that even if I change the current directory by
opening a file from a different directory, when the sub runs, the
directory will be set to specific folder when I use the show command
for the open dialogue box.

This is my code, but for some reason doesn't open the proper
directory and only opens whatever the last directory opened in the
application. Dim OBJ As Object
Set OBJ = GetObject(, "EXCEL.APPLICATION")
Dim SPATh As String
OBJ.Visible = True
SPATh = "C:\SCR DATABASE\CURRENT YEAR Data And Charts\SCR\SCR
SUMMARY" ChDrive SPATh
ChDir SPATh
OBJ.Application.Dialogs(xlDialogOpen).Show

Have you tried this:

OBJ.Application.Dialogs(xlDialogOpen).Show SPATh

?
 
Back
Top