Hi,
i have a button in access that runs a macro to ouput to excel, i have also written into the same button code to open a second excel file.
The second excel file has code written into it to run a macro on open and is linked to the download file.
The problem i have is that when the macro finishes in the second excel file the database code causes the error message "Subscript out of range"
the code in the button is as follows :
Public Sub ExcelD1_Click()
On Error GoTo Err_ExcelD1_Click
Dim stdocname As String
stdocname = "ExcelExp1"
DoCmd.RunMacro stdocname
Dim path As String
Dim a As Excel.Application
Dim b As Excel.Workbook
Dim c As Excel.Worksheet
path = "\\t001dfsd3.axa-uk.intraxa\shared3\union_a_sales\planning\Team\(7) Andrew Morfey\Payroll DB Excel Download Files\"
path = path + "ExpWholeFormatted.xls"
Set a = CreateObject("Excel.Application")
Set b = GetObject(path)
Set c = b.Worksheets(Sheet1)
Exit_ExcelD1_Click:
Exit Sub
Err_ExcelD1_Click:
MsgBox Err.Description
Resume Exit_ExcelD1_Click
End Sub
Any help appreciated,
Thanks,
i have a button in access that runs a macro to ouput to excel, i have also written into the same button code to open a second excel file.
The second excel file has code written into it to run a macro on open and is linked to the download file.
The problem i have is that when the macro finishes in the second excel file the database code causes the error message "Subscript out of range"
the code in the button is as follows :
Public Sub ExcelD1_Click()
On Error GoTo Err_ExcelD1_Click
Dim stdocname As String
stdocname = "ExcelExp1"
DoCmd.RunMacro stdocname
Dim path As String
Dim a As Excel.Application
Dim b As Excel.Workbook
Dim c As Excel.Worksheet
path = "\\t001dfsd3.axa-uk.intraxa\shared3\union_a_sales\planning\Team\(7) Andrew Morfey\Payroll DB Excel Download Files\"
path = path + "ExpWholeFormatted.xls"
Set a = CreateObject("Excel.Application")
Set b = GetObject(path)
Set c = b.Worksheets(Sheet1)
Exit_ExcelD1_Click:
Exit Sub
Err_ExcelD1_Click:
MsgBox Err.Description
Resume Exit_ExcelD1_Click
End Sub
Any help appreciated,
Thanks,