ItayM
ItayM

Reputation: 912

Excel Vba Workbook_open stop working

I have an file with VBA macro that starts when the Workbook is opening by user. One of the users added Protection Login password to this file, and now the Workbook_open() doesn't react anymore.

It is

Any Ideas?

Upvotes: 2

Views: 1213

Answers (2)

brettdj
brettdj

Reputation: 55682

Seeing the full code as per Reafidy's comment would help

It sounds like the user is still running code if they have looked to modify it. But it is possible that this user (or other users in the future) may chose to disable macros, or corporate policy may automatically disable macros

If it's user choice then a standard technique is to hide all the worksheets except an splashscreen informing the user that they need to enable macros. If they have enabled macros then all the VeryHidden sheets (cannot be revealed by the standard menu) are made visible and the splashscreen is hidden when the workbook opens

You could combine Brad's splash screen code with your existing Open code

Upvotes: 2

amccormack
amccormack

Reputation: 13927

There are a couple of options listed from this website

Try using the additional password parameter like this:

Sub OpenBookTest()
Dim myFile As String
Dim myPath As String
myPath = "C:\My Documents"
myFile = "My Workbook.xls"
Workbooks.Open myPath & "\" & myFile, password:="password"
End Sub

Or written another way:

Workbooks.Open "Full Path Name", Password: ="XYZ"

After looking through MSDN, I'm guessing that your Workbook_Open is a custom sub routine that you wrote (or copied from somewhere online). If that is the case then you will need to edit it to allow an additional password parameter. You should edit your question and post your Workbook_Open routine. That way we will know how to help you.

Upvotes: 0

Related Questions