O
Opal
Running Access 2003, I have the following code to open an
excel file:
Sub ExcelOpen()
Dim xlApp As Excel.Application
Dim xlWkb As Excel.Workbook
Dim xlWsh As Excel.Worksheet
On Error Resume Next
' reference open session of excel
Set xlApp = GetObject(, "excel.application")
If Err.Number <> 0 Then
' excel not already running
Err.Clear
On Error GoTo 0
Set xlApp = New Excel.Application
xlApp.Visible = True
End If
On Error GoTo 0
Set xlWkb = xlApp.Workbooks.Open("C:\My Documents\Andon
\NewDTTracking.xls")
Set xlWsh = xlWkb.Worksheets("Report")
xlWsh.Activate
'With xlApp
'If Not .UserControl Then
'' opened excel using code
'.Quit
'End If
'End With
Set xlWsh = Nothing
Set xlWkb = Nothing
Set xlApp = Nothing
End Sub
How can I amend it to open a file that is
password protected?
excel file:
Sub ExcelOpen()
Dim xlApp As Excel.Application
Dim xlWkb As Excel.Workbook
Dim xlWsh As Excel.Worksheet
On Error Resume Next
' reference open session of excel
Set xlApp = GetObject(, "excel.application")
If Err.Number <> 0 Then
' excel not already running
Err.Clear
On Error GoTo 0
Set xlApp = New Excel.Application
xlApp.Visible = True
End If
On Error GoTo 0
Set xlWkb = xlApp.Workbooks.Open("C:\My Documents\Andon
\NewDTTracking.xls")
Set xlWsh = xlWkb.Worksheets("Report")
xlWsh.Activate
'With xlApp
'If Not .UserControl Then
'' opened excel using code
'.Quit
'End If
'End With
Set xlWsh = Nothing
Set xlWkb = Nothing
Set xlApp = Nothing
End Sub
How can I amend it to open a file that is
password protected?