我从Outlook写了一个宏来打开Excel。
代码下方:
Public Sub OpenMasterPM()
Dim xExcelFile As String
Dim xExcelApp As Excel.Application
Dim xWb As Excel.Workbook
Dim xWs As Excel.Worksheet
Dim xExcelRange As Excel.Range
xExcelFile = "C:\Users\andrea.vighetti\Documents\Banca5\Evolutive\Master PM_prova.xlsm"
Set xExcelApp = CreateObject("Excel.Application")
Set xWb = xExcelApp.Workbooks.Open(xExcelFile)
Set xWs = xWb.Sheets(1)
xWs.Activate
xExcelApp.Visible = True
End Sub
之后,Excel是打开的,我在Excel上有一个Auto_Open
宏,我希望在该页面打开时启动,但这不起作用。
似乎Excel上写的自动打开宏不会启动Excel从Outlook宏开始打开时,在Excel上的vba代码下面:
Sub Auto_open()
Sheets("Evolutive TFS").Select
ActiveWorkbook.RefreshAll
Sheets("Gantt").Select
ActiveSheet.ListObjects("Gantt").Range.AutoFilter Field:=3, Criteria1:="=Implementation", Operator:=xlOr, Criteria2:="=Test"
End Sub
Auto_open
使用Workbook.Open Event因为Auto_open
已经过时了。
把它放入ThisWorkbook
而不是模块!Private Sub Workbook_Open()
Sheets("Evolutive TFS").RefreshAll
Sheets("Gantt").ListObjects("Gantt").Range.AutoFilter Field:=3, Criteria1:="=Implementation", Operator:=xlOr, Criteria2:="=Test"
End Sub