Open an Explorer Window using VBA
Posted on 2011-02-28
I am trying to develop a document management application that uses an Access Data Project front-end. Data about [construction] projects is stored in a MS-SQL database, and I want to use the front end to link to a directory structure on the file server where project related files can be stored. I am using a form to present the project information to the user, and want to give him a button that will open up the relevant folder in a windows explorer window.
I am very new to VBA and cannot seem to get Shell or ShellExecute to work. My latest attempt is listed below. It returns `Run time error '53': File not found.'
Private Sub cmdOpenFolder_Click()
Dim strFolder, strCommand As String
Dim x As Variant
strFolder = "c:\" 'ideally this will be a value from the current record
strCommand = Chr(34) & "EXPLORER.EXE" & strFolder & Chr(34)
x = Shell(strCommand, vbNormalFocus)
SQL Server 2000
Windows Server 2003/SP2