1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Dim objExcelApp
Dim FileName, AppName
Dim msg
Dim ExcelObj
Dim ExcelWb
Dim Found
FileName = "D:\Mon ficher.xls"
AppName = "Microsoft Excel"
Set ExcelObj = CreateObject("Excel.Application")
Set ExcelObj = GetObject(, "Excel.Application")
On Error Goto 0
For Each ExcelWb In ExcelObj.Workbooks
'MsgBox excelwb.Name
If ExcelWb.Name = "Mon ficher.xls" Then
Found = True
MsgBox "Mon ficher.xls already opened, switching to excel..."
Exit For
End If
Next
If Not found Then
Set ExcelWb = ExcelObj.Workbooks.Open(FileName)
End If
ExcelObj.Visible = True
Exit Sub |
Partager