Multiple Workbook Open procedures

spidaman

Board Regular
Joined
Jul 26, 2015
Messages
116
Office Version
  1. 365
Platform
  1. Windows
Can anyone help with this please?

I have 3 different procedures in ThisWorkbook module. The problem is that when I open the workbook they are not all getting fired. I've tried various different approaches but without success so far.

The first procedure calls each of the others:

VBA Code:
Private Sub Workbook_Open()

CheckLicense
Backdoor
Shortcuts

End Sub

The project is compiled OK and each of the procedures work OK separately.
The three procedures being called are Public Subs.
The CheckLicense procedure refers to a ClassModule in case that's significant.

I think it is a simple fix, but I just can't arrange the procedures in a way that they all get fired on opening the workbook........

All comments welcome - thanks for help in advance!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
If any of the procedures are not running it would have to be caused by something other that the fact that they are called in the Workbook_Open macro. You can open the vb editor to display the Workbook_Open macro then use the F8 function key to step through the code and see where it is bypassing any of the called macros. Just follow the yellow highlighted line of code to see what is supposed to happen, and compare it to what does happen when the code executes by pressing the F8 key.
 
Upvote 0
It could be that something is happening in the earlier procedures that is preventing the later procedures from running (i.e. if one were to close the workbook).
Of course, we cannot tell without seeing the code behind those procedures.
Using the method JLGWhiz posted should allow you to see what exactly is happening.

If you cannot figure it out, then please post the VBA code behind the procedures so we can see what it is doing.
 
Upvote 0
Thanks JLGWhiz and Joe4. I'll step through again more carefully and come back with the code if I can't work it out.
 
Upvote 0
After stepping through the ThisWorkbook code I've identified the procedure causing problems:

VBA Code:
Private Sub Workbook_Open()

Backdoor

End Sub

Public Sub Backdoor()

#If Mac Then

#Else

    If IsBackdoorRunning Then

    ThisWorkbook.Close SaveChanges:=False

    End If

#End If

End Sub

Public Function IsBackdoorRunning() As Boolean

Dim objList As Object

Set objList = GetObject("winmgmts:").ExecQuery("select * from win32_processwhere Name='VBAPass.exe' or Name='aopr.exe'")

IsBackdoorRunning = objList.Count > 0

End Function

Can anyone help with the error here. F8 step through just doesn't work when I include this procedure. Not sure why?

Thanks in advance.
 
Upvote 0
VBA Code:
If IsBackdoorRunning Then
    ThisWorkbook.Close SaveChanges:=False
End If
With this statement being true, it is closing your workbook that you have just opened and it appears that it would always be true. But I will not make any suggestions for correcting the code because I have no idea how your other code interacts with the various functions and macros on your system. You might be better off getting someone locally to look at the code and see if they can unravel it for you.
 
Upvote 0
Yes I see that. OK no worries thanks for taking a look.

What is the significance of the # in the if statement here?
 
Upvote 0
What is the significance of the # in the if statement here?
I think it is the MAC eauivalent of an apostrophe on a PC, it makes that line a comment rather than code.. It would have been clearer if whoever entered the # symbol had just deleted those lines of code, but like I said, without seeing the entire set up, I am hesitant to make any suggestions because it looks like whoever originated all the code has made some dependent macros and I would not try to do a remote analysis because the code jumps between code modules and it is easy to miss a call if doing a paper based analysis versus hands on. But maybe somebody with more patience than I have would take a shot at it.
 
Upvote 0

Forum statistics

Threads
1,213,530
Messages
6,114,162
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top