Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default VBE takes two tries to hear me clearly...

OK, so I edit my VBA a lot. In Word, I made sneaky macros to
quickly open my add-ins, etc., in the VBA editor and display
specific code modules. Now that I'm soaking in Excel, I tried
the same sort of code, and it SORT OF works:

Sub EditMT()
Dim w As Workbook
Set w = Workbooks.Open(Filename:="C:\Path\MTstuff.XLS")
w.VBProject.VBComponents("Module1").CodeModule.Cod ePane.Show
End Sub

Now, what would cause this to show a totally different VBA
project the *first* time it's run during an Excel session.
(Typically it shows the project that's alphabetically first
in the project explorer, if that means anything). It works
properly for the rest of the session. (Of course, the first
time tends to be when I want it open most urgently!)

I have 4 custom buttons to open different projects, and they
misbehave identically, so it's not related to the file being
opened.

TIA

--
Mark Tangard , Microsoft Word MVP
"Life is nothing if you're not obsessed." --John Waters
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default VBE takes two tries to hear me clearly...

Hi keepITcool,

Thanks for this. It looked promising, but it didn't change
the behavior. First, for some reason the very last line
throws a 'variable not found' error, and it highlights the
'VBE' -- ehhh? (The VBA extensibility library *is* added
in references.) So I preceded that with 'Application.' and
it stopped complaining, but the problem continued.

When I inserted an 'On Error GoTo 0' after the End If, then,
on this line:

wkb.VBComponents("Module1").Activate

I get an non-supported property/method error. Fixed that
by using:

wkb.VBProject.VBComponents("Module1").Activate

But the behavior continues. I added an Application.OnTime
statement at the end and moved the last line (the .Show)
into its own macro, to run 1 second later. Still no change.

Grrr. What could be wrong??

Thanks again for following up.

--
Mark Tangard , Microsoft Word MVP
"Life is nothing if you're not obsessed." --John Waters

keepitcool wrote:

Mark,

try this:
1.checks to see if opened, if not does.
2.activates codemodule
3.activates VBE

Sub EditMT()
Dim wkb As Workbook
Const csPath = "c:\path\"
Const csName = "mtstuff.xls"
On Error Resume Next
Set wkb = Workbooks(csName)
If wkb Is Nothing Then
Set wkb = Workbooks.Open(csPath & csName)
End If
wkb.VBComponents("Module1").Activate
VBE.ActiveCodePane.Show
End Sub

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool

Mark Tangard wrote:


Sub EditMT()
Dim w As Workbook
Set w = Workbooks.Open(Filename:="C:\Path\MTstuff.XLS")
w.VBProject.VBComponents("Module1").CodeModule.Cod ePane.Show
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBE takes two tries to hear me clearly...

hmm..

xlXP is more forgiving... i've checked in xl97 and it runs flawlessly.

A reference to extensibility is not needed.
I (and the code) assume that MTSTUFF contains a module named "Module1"

Hope you dont have a Password on your VBA code?????
Check macrosecurity/ trusted sources : Trust access to VB project

Included a DoEvents..
I dont know which events mtstuff is running on opening (which should be
no problem, but you could insert a few debug.print lines to see who does
what in which sequence....


Sub EditMT()
Dim wkb As Workbook
Const csPath = "c:\path"
Const csName = "mtstuff.xls"
On Error Resume Next
Set wkb = Workbooks(csName)
On Error GoTo 0
If wkb Is Nothing Then
Set wkb = Workbooks.Open(csPath & csName)
End If
Do Events
wkb.VBProject.VBComponents("Module1").Activate
Application.VBE.ActiveCodePane.Show
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


Mark Tangard wrote:

Hi keepITcool,

Thanks for this. It looked promising, but it didn't change
the behavior. First, for some reason the very last line
throws a 'variable not found' error, and it highlights the
'VBE' -- ehhh? (The VBA extensibility library *is* added
in references.) So I preceded that with 'Application.' and
it stopped complaining, but the problem continued.

When I inserted an 'On Error GoTo 0' after the End If, then,
on this line:

wkb.VBComponents("Module1").Activate

I get an non-supported property/method error. Fixed that
by using:

wkb.VBProject.VBComponents("Module1").Activate

But the behavior continues. I added an Application.OnTime
statement at the end and moved the last line (the .Show)
into its own macro, to run 1 second later. Still no change.

Grrr. What could be wrong??

Thanks again for following up.

--
Mark Tangard , Microsoft Word MVP
"Life is nothing if you're not obsessed." --John Waters

keepitcool wrote:

Mark,

try this:
1.checks to see if opened, if not does.
2.activates codemodule
3.activates VBE

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default VBE takes two tries to hear me clearly...


Damn....

This is XL2000, tested on 2 different machines (one Win98, one Win2K),
fails on both! Yes, there's a module Module1, and no password, and
security all happy. MTStuff doesn't run anything when opened, isn't
even an add-in yet (will be later). Feh.

Well, it's not a horrible thing. Sometimes this stuff fixes itself
overnight too. Thanks again.

--
Mark Tangard , Microsoft Word MVP
"Life is nothing if you're not obsessed." --John Waters

keepitcool wrote:

hmm..

xlXP is more forgiving... i've checked in xl97 and it runs flawlessly.

A reference to extensibility is not needed.
I (and the code) assume that MTSTUFF contains a module named "Module1"

Hope you dont have a Password on your VBA code?????
Check macrosecurity/ trusted sources : Trust access to VB project

Included a DoEvents..
I dont know which events mtstuff is running on opening (which should be
no problem, but you could insert a few debug.print lines to see who does
what in which sequence....

Sub EditMT()
Dim wkb As Workbook
Const csPath = "c:\path"
Const csName = "mtstuff.xls"
On Error Resume Next
Set wkb = Workbooks(csName)
On Error GoTo 0
If wkb Is Nothing Then
Set wkb = Workbooks.Open(csPath & csName)
End If
Do Events
wkb.VBProject.VBComponents("Module1").Activate
Application.VBE.ActiveCodePane.Show
End Sub

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool

Mark Tangard wrote:

Hi keepITcool,

Thanks for this. It looked promising, but it didn't change
the behavior. First, for some reason the very last line
throws a 'variable not found' error, and it highlights the
'VBE' -- ehhh? (The VBA extensibility library *is* added
in references.) So I preceded that with 'Application.' and
it stopped complaining, but the problem continued.

When I inserted an 'On Error GoTo 0' after the End If, then,
on this line:

wkb.VBComponents("Module1").Activate

I get an non-supported property/method error. Fixed that
by using:

wkb.VBProject.VBComponents("Module1").Activate

But the behavior continues. I added an Application.OnTime
statement at the end and moved the last line (the .Show)
into its own macro, to run 1 second later. Still no change.

Grrr. What could be wrong??

Thanks again for following up.

--
Mark Tangard , Microsoft Word MVP
"Life is nothing if you're not obsessed." --John Waters

keepitcool wrote:

Mark,

try this:
1.checks to see if opened, if not does.
2.activates codemodule
3.activates VBE

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Did you hear that Frank? Kevin wants you to become Alias #3, Just FYI Spanky deMonkey Excel Discussion (Misc queries) 0 March 21st 08 11:25 PM
Why can I not hear the words recorded on powerpoint? Sonshine Excel Discussion (Misc queries) 1 October 2nd 07 09:16 PM
Event (BeforeSave) - How to test VBA code? Dave P. can you hear me now? EagleOne Excel Discussion (Misc queries) 3 September 14th 06 07:46 PM
anyone ever hear of a formula beginning "xlend"? excelmix Excel Discussion (Misc queries) 3 September 11th 06 02:00 PM
Saving so others can hear linked sound dfalgoust Excel Discussion (Misc queries) 0 August 27th 06 11:55 PM


All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"