Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi gang. This a simple macro to open the VBE to a given module of a
given workbook for editing. It work perfectly for any workbook except the Personal Macro Workbook. Is the PMW under some vague (if not sloppy) protection as this implies? Dim w As Workbook Set w = Workbooks.Open(Filename:="J:\Test.xls") w.VBProject.VBComponents("Bzzz").CodeModule.CodePa ne.Show SendKeys "^{end}" (In case you’re wondering, the macro does not live *in* the PMW.) For any other workbook, this code brings up the Bzzz module in the foreground. When tried on the PMW it does indeed open the VBE but the foreground code window is chosen seemingly at random. Any of its 4 regular modules may end up with the focus, as well as the one userform code window. The only window that never comes up is ThisWorkbook. Often (but not consistently) the FIRST attempt in a given session brings up the correct module, but the majority of later attempts won’t. The workbook isn’t very old, hasn’t been terribly active, and has never been fed poor-quality meat. I’ve experimented with the lines below, in various permutations, in addition to (and instead of) the .Show line above. Nothing seems to make a difference. w.VBProject.VBComponents("Module3").CodeModule.Cod ePane.Show w.VBProject.VBComponents("Module3").CodeModule.Cod ePane.Window.SetFocus w.VBProject.VBComponents("Module3").Activate Is there a secret to this? TIA TIA TIA. ----------------------- Mark Tangard "Life is nothing if you're not obsessed." --John Waters |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
code works - need to save | Excel Discussion (Misc queries) | |||
Code works within VBE but not from Excel | Excel Programming | |||
Code works but I have to run it 4 times | Excel Programming | |||
Why won't this code works | Excel Programming | |||
VBA Code Works in 97, Not in 2002 | Excel Programming |