|
|
Запуск макроса в книге MS Excel (из библеотеки личных макросов)
Private Sub TestExcelMacro()
Dim XLApp As Object
Dim s$
On Error GoTo TestExcelMacro_Err
Set XLApp = CreateObject("Excel.Application")
With XLApp
.Application.Visible = True
.UserControl = True
s = Environ("UserProfile") & "\AppData\Roaming\Microsoft\Excel\XLSTART\PERSONAL.xlsb"
.Workbooks.Open s, True
.Workbooks.Open "d:\Temp\MyFile.xlsx", False
.Run "PERSONAL.xlsb!mmm01Macro"
.ActiveWorkbook.Close True
.Quit
End With
TestExcelMacro_Bye:
On Error Resume Next
Set XLApp = Nothing
Exit Sub
TestExcelMacro_Err:
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in Sub: TestExcelMacro in module: [Имя Модуля]", vbCritical, "Error in Application: " & Err.Source
Err.Clear
Resume TestExcelMacro_Bye
End Sub
|
|