|
-
Aug 11th, 2005, 05:06 PM
#1
Thread Starter
New Member
Bypass Workbook_Open
I am opening a workbook via VBA that has the Workbook_Open event in it. How do you bypass the Workbook_Open Even in code.
-
Aug 11th, 2005, 05:26 PM
#2
Re: Bypass Workbook_Open
I'm not sure you can.. you can open a workbook that has a module with Auto_Open in it.. but it will run the Workbook_Open code regardless..
There is no parameter to prevent this.. If it is your own workbook then I suggest you change it to Auto_Open in a module instead..
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 12th, 2005, 11:02 AM
#3
Re: Bypass Workbook_Open
Sopunds like you are opening this workbook from within another workbooks vba code. So not too much you can do. If its in your primary workbook you can do this.
VB Code:
Private Sub Workbook_Open()
'Bypass
Exit Sub
'Other open code
'Blah, blah, blah
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2005, 11:13 AM
#4
Re: Bypass Workbook_Open
Not meaning to re-start the fight but the Auto_open procedure inside a module will not run unless you specify to run it..
for example
VB Code:
Sub WorkBook_Open()
Msgbox "Workbook open event performed."
End Sub
'in a module (Not ThisWorkbook or behind any sheets)
Sub Auto_Open()
Msgbox "Auto open procedure performed."
End Sub
Save that into a workbook and then from a second workbook simply do
VB Code:
Workbooks.Open("C:\MyWorkbook.xls")
And see which msgbox appears.. you should only get the workbook event.. if however you follow your workbook open code with the following
VB Code:
ActiveWorkbook.RunAutoMacros xlAutoOpen
Then you should see both messages..
The Auto_Open method does not fire unless coded specifically, whereas the Workbook_Open will fire regardless.. (Unless of course you have the security set to high)
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 12th, 2005, 11:23 AM
#5
Re: Bypass Workbook_Open
Right, but if the second workbook can not be modified then that workbooks Open event will fire.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2005, 11:25 AM
#6
Re: Bypass Workbook_Open
Correct and if it is locked then there is nothing you can do to change it, apart from set the security higher..
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 12th, 2005, 11:37 AM
#7
Re: Bypass Workbook_Open
Instead of going through all this, what is the reason you need to bypass the open event for it? Maybe there is another way to look at this?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2005, 01:23 PM
#8
Thread Starter
New Member
Re: Bypass Workbook_Open
I need to bypass Workbook_open Event because what I am doing is I have an Excel workbook that in code opens up other Excel files and parses the data. One of the files has the Workbook_open Event to add a command bar that references an Addin I don't have access to. So my Automation fails.
-
Aug 12th, 2005, 01:36 PM
#9
Re: Bypass Workbook_Open
Is the file locked down or can you access the VBA behind it.. If so change it to the Auto_Open in a module instead.. It will still fire when the workbook is opened normally
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Aug 12th, 2005, 01:39 PM
#10
Re: Bypass Workbook_Open
If that was the case wouldnt that have been done before a thread was posted?
How about copying the file, making it writeable, change the vba code and be done with it?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2005, 01:45 PM
#11
Thread Starter
New Member
Re: Bypass Workbook_Open
Everyday I receive numerious Excel Files with different data everyday from different sources. The source that sends the file will not remove the code or module. I am trying to complety automating parsing the data. Setting the security to High actually doesn't work in this instance.
-
Aug 12th, 2005, 01:47 PM
#12
Re: Bypass Workbook_Open
Setting the security to high will probably prevent your code from working..
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|