打开工作表启动VBAmacros
我如何通过打开一个Excelsheet来启动一个macros。 我已经把这个代码:
Public Sub Workbook_Open() Application.ScreenUpdating = False With Tabelle1.ListBox1 .AddItem "TEST1" .AddItem "TEST2" .AddItem "TEST3" End With With Tabelle1.ListBox2 .AddItem "TEST4" .AddItem "TEST5" End With With Tabelle1.ListBox1 .Width = 140.25 .Height = 255.25 End With With Tabelle1.ListBox2 .Width = 78 .Height = 69.75 End With Call EnterInDesignMode Call ExitInDesignMode Application.ScreenUpdating = True End Sub
进入Private Sub Workbook_Open()
。 但是它不会去第二个代码。 我在这里做错了什么?
两个代码都在Public Sub Workbook_Open()
之上
'first Code Sub EnterInDesignMode() With Application.CommandBars.FindControl(ID:=1605) .Execute End With End Sub 'Second Code Sub ExitInDesignMode() Dim sTemp As String With Application.CommandBars("Exit Design Mode") sTemp = .Controls(1).Caption End With End Sub
两个代码都可以工作,但不会停止对EnterInDesignMode()
的调用,所以它不调用ExitInDesignMode()
。
With CommandBars("Exit Design Mode").Controls(1) If .State = msoButtonDown Then .Execute End With
编辑你所拥有的代码,就像我在评论过的链接中发表的那样。
来源: https : //groups.google.com/forum/#!topic/ microsoft.public.excel.programming/ XN27a-Gxz6g