I need help, :banghead: my brain has melted and I hope someone can assist.
I am trying to run the following code as a function in Access 2010:
"Run-time error '1004': The macro may not be available in this workbook or all macros may be disabled"
Yet, when I run the code in Excel, it works perfectly. Please help!
I am trying to run the following code as a function in Access 2010:
Public Function OpenAMZOrder()
Dim xl As Object
'Step 1: Start Excel, then open the target workbook.
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open ("\\MACSERV8 \Company \Customer Service\ Issues FE File\Data\AMZOrder.xlsm")
'Step 2: Make Excel visible
xl.Visible = False
'Step 3: Run the target macro
xl.Run "Data_Refresh"
xl.Run "Clear_Fields"
xl.Run "Insert_Formula"
'Step 4: Close and save the workbook, then close Excel
xl.ActiveWorkbook.Close (True)
xl.Quit
'Step 5: Memory Clean up.
Set xl = Nothing
End Function
When I try to call it out, it gives me the following error:Dim xl As Object
'Step 1: Start Excel, then open the target workbook.
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open ("\\MACSERV8 \Company \Customer Service\ Issues FE File\Data\AMZOrder.xlsm")
'Step 2: Make Excel visible
xl.Visible = False
'Step 3: Run the target macro
xl.Run "Data_Refresh"
xl.Run "Clear_Fields"
xl.Run "Insert_Formula"
'Step 4: Close and save the workbook, then close Excel
xl.ActiveWorkbook.Close (True)
xl.Quit
'Step 5: Memory Clean up.
Set xl = Nothing
End Function
"Run-time error '1004': The macro may not be available in this workbook or all macros may be disabled"
Yet, when I run the code in Excel, it works perfectly. Please help!