Syntax-Change?

P

Peter Ostermann

Hi folks,
migrating from Excel 2000 to 2003, I realize that
the VBA-code may have changed in some parts.

The routine below, called when workbook
opens - quite helpful at times when a bit of
programming is done - in 2003 produces
an error:

Sub OpenMainWindow()
' On Error Resume Next
With Application.VBE.MainWindow
.Visible = True
.SetFocus
End With
End Sub

Is there any known workaround available?
Thanks in advance for any hint.

Best Regards
Peter Ostermann
 
R

RichardSchollar

Hi Peter

Does it actually error out on a particular line in the sub you
posted? I ask because it causes no errors on my machine (xl2003 and
XP SP2). How are you calling that sub on opening of the workbook? Is
it a line in the WorkBook_Open event such as:

Private Sub Workbook_Open()
OpenMainWindow
End Sub

Best regards

Richard
 
G

Guest

In one of my workbooks, I include a dummy sub called demo:

Sub demo()

End Sub

In ThisWorkbook code, I include:


Private Sub Workbook_Open()
Application.Goto "demo"
End Sub

This is enough to open the VBE and give it focus.
 
G

Guest

Put the same code in the workbook open macro

Private Sub Workbook_Open()
On Error Resume Next
With Application.VBE.MainWindow
.Visible = True
.SetFocus
End With

End Sub
 
P

Peter Ostermann

Gotcha!

Hi fellows,

thanks for your hints.
In the meantime I found the solution which
I like to share with you.

Since I have the German edition, my translation
may be wrong, but I will try:

tools-> macros -> security -> registertab: "trustable publishers"
There just hook the rectangle: trust access to visual basic project

Best Regards
Peter Ostermann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top