yooperboy877
New Member
- Joined
- Jun 14, 2016
- Messages
- 43
I'm flummoxed by a situation I keep encountering, and am hoping that someone can shed light on this issue.
I have an Excel workbook with a series of Macros I want to run on startup. The first macro goes out to refresh data from an external SQL source. That refresh works perfectly when I configure the external connection to refresh on file opening. It also works when I click a button to which the relevant macro has been assigned. That macro is
As originally set up, I manually triggered, using a button, a series of additional macros that sorted my data into other worksheets based on various criteria. That too works perfectly in manually mode. The button in question runs the following:
What is causing problems is when I disable all, and then try to run all of the macros on file opening. I attempt to do that with a module located in This Workbook, coded as follows:
Every time I run the workbook with the Workbook_Open macro, it crashes on the Data_Refresh portion, returning a 1004 error on the very first line. I get the same error when I open the Developer tab and try to run the Data_Refresh macro from there.
Why can I do this in the background and manually via button, but I can't do it automatically or through the Developer area?
Many thanks for the help on this.
I have an Excel workbook with a series of Macros I want to run on startup. The first macro goes out to refresh data from an external SQL source. That refresh works perfectly when I configure the external connection to refresh on file opening. It also works when I click a button to which the relevant macro has been assigned. That macro is
Code:
Sub Data_Refresh()
'
' Data_Refresh Macro
'
' Keyboard Shortcut: Ctrl+Shift+R
'
Range("Table_iMan_BNALegal_vwWorkSpaceReport[[#Headers],[Project Name]]"). _
Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
End Sub
As originally set up, I manually triggered, using a button, a series of additional macros that sorted my data into other worksheets based on various criteria. That too works perfectly in manually mode. The button in question runs the following:
Code:
Sub Run_All_Macros()
A_ClearAllOldContents
B_ClearWorkingData
C_CopyDataRangeToWorking
D_CopyOpenContractMatters
E_CopyNewContractMatters
F_CopyClosedContractMatters
CopyOpenDJWCases
CopyOpenFMCases
CopyOpenJLCases
CopyOpenJHCases
CopyOpenSECases
CopyOpenKZCases
CopyOpenRLCases
CopyOpenUnassignedCases
CopyOpenOthersCases
End Sub
What is causing problems is when I disable all, and then try to run all of the macros on file opening. I attempt to do that with a module located in This Workbook, coded as follows:
Code:
Private Sub Workbook_Open()
Data_Refresh
A_ClearAllOldContents
B_ClearWorkingData
C_CopyDataRangeToWorking
D_CopyOpenContractMatters
E_CopyNewContractMatters
F_CopyClosedContractMatters
CopyOpenDJWCases
CopyOpenFMCases
CopyOpenJLCases
CopyOpenJHCases
CopyOpenSECases
CopyOpenKZCases
CopyOpenRLCases
CopyOpenUnassignedCases
CopyOpenOthersCases
End Sub
Every time I run the workbook with the Workbook_Open macro, it crashes on the Data_Refresh portion, returning a 1004 error on the very first line. I get the same error when I open the Developer tab and try to run the Data_Refresh macro from there.
Why can I do this in the background and manually via button, but I can't do it automatically or through the Developer area?
Many thanks for the help on this.