Forum Discussion
VBA Code stops
Not sure what is going on... this was working and now all the sudden the code stops part way through.
Here is the current code (linked to a button)
Private Sub CommandButton2_Click()
Dim cofCom As Object
Set cofCom = Application.COMAddIns("SapExcelAddIn").Object
Dim api As Object
Set api = cofCom.GetPlugin("com.sap.epm.FPMXLClient")
api.RefreshActiveWorkbook
Application.ScreenUpdating = False
ActiveWorkbook.Sheets("Spend Detail").Activate
Sheet14.CommandButton2_Click
Sheet14.CommandButton1_Click
ActiveWorkbook.Sheets("Spend Detail 1").Activate
Sheet21.CommandButton4_Click
Sheet21.CommandButton3_Click
ActiveWorkbook.Sheets("Spend Detail 2").Activate
Sheet22.CommandButton6_Click
Sheet22.CommandButton5_Click
ActiveWorkbook.Sheets("Spend Detail 3").Activate
Sheet23.CommandButton8_Click
Sheet23.CommandButton7_Click
ActiveWorkbook.Sheets("Spend Detail 4").Activate
Sheet24.CommandButton10_Click
Sheet24.CommandButton9_Click
ActiveWorkbook.Sheets("Spend Detail 5").Activate
Sheet25.CommandButton12_Click
Sheet25.CommandButton11_Click
ActiveWorkbook.Sheets("Spend Detail 6").Activate
Sheet27.CommandButton14_Click
Sheet27.CommandButton13_Click
ActiveWorkbook.Sheets("Finance Input Sheet").Activate
Application.ScreenUpdating = True
End SubThe problem is that all tabs update for the refresh but for some reason, going to each sheet and clicking the buttons is not occurring now. It is essentially stopping at line 6 and I have tried removing the screenupdating false and true and that did not make any difference. Just like for some reason the code stops and it was working a week ago.
Any suggestions?
1 Reply
- AOSPWBBrass Contributor
Okay... did some trial and error and found it had to do with "trusted" documents and for some reason, the enable content was not "enabling" properly. Took off trusted documents and have to click on enable content when it opens and now it works.... however, does anyone have any ideas as to how I could force the file to only refresh specific tabs and not all the tabs? (time saver)... most of the files only need a couple tabs updated while others need all, so if I create a button to give the choice it will save time.