rediffusion
rediffusion

Reputation: 75

How do I open a Visual Basic when I start Excel?

I find this code on site.

Private Sub Workbook_Open()
    UserForm1.Show
End Sub

It's not working. I want to open «Visual Basic» after starting Excel then open the window Module1 for example. Is it feasible?

Upvotes: 0

Views: 142

Answers (3)

user1100264
user1100264

Reputation:

Note that Private Sub Workbook_Open() should be located in ThisWorkbook, not in a module, if so, then it's not being called.

Upvotes: 1

Tim Stack
Tim Stack

Reputation: 3248

To open the Virtual Basic Editor (VBE) on a specific module, try the following

Private Sub Workbook_Open()
    Application.VBE.MainWindow.Visible = True
    Me.VBProject.VBComponents("Module1").Activate
End Sub

Upvotes: 2

L8n
L8n

Reputation: 738

Alternative to @TimStack:
(althought I do prefer his Method)

Private Sub Workbook_Open()
    SendKeys "%{F11}"
End Sub

Upvotes: 0

Related Questions