|
|
MS Excel - Перехват уже открытой (локально) книги
Private Sub Process_ExcelWorkBook()
Dim app As Object, wrk As Object
Dim s$, wbIsOpen As Boolean
s = "d:\Temp\Расчет ТОП-5.xlsm"
On Error Resume Next
Set app = GetObject(, "Excel.Application")
If Err.Number = 429 Then
Debug.Print "Microsoft Excel не запущен. - Запускаем ...."
Debug.Print String(72, "-")
Err.Clear
Set app = CreateObject("Excel.Application")
End If
app.Visible = True
For Each wrk In app.WorkBooks
If wrk.FullName = s Then
wbIsOpen = True
Exit For
End If
Next wrk
If wbIsOpen = False Then
Set wrk = app.WorkBooks.Open(s)
End If
wrk.Save
app.WindowState = -4140
End Sub
|
|