Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Lista Forumurilor Pe Tematici
|
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login
POZE MRRRR'S FORUM (VIEW ONLY)
Nu sunteti logat.
|
Nou pe simpatie: LaraTaner la Simpatie.ro
| Femeie 19 ani Prahova cauta Barbat 24 - 52 ani |
|
TRaP
Moderator
Inregistrat: acum 6 ani
Postari: 787
|
|
To test, paste the following code in Notepad and save as .vbs
Change the name of your Excel file accordingly. Mind the extension - I noticed that uppercase (.XLSX) or lowercase (.xlsx) extension makes a difference - code won't work the same for both.
'Note: your file might have lowercase extension, you will have to change it to lowercase, otherwise it won't work ExcelFileName = "export.XLSX" If objXL Is Nothing Then MsgBox "There is no Excel file open.", vbOkOnly, "Excel not found!" Exit Sub End If On Error Resume Next Set xl = GetObject(, "Excel.Application") 'attach to running Excel instance
If Err Then If Err.Number = 429 Then WScript.Echo "Excel is not running (workbook not open)." Else WScript.Echo Err.Description & " (0x" & Hex(Err.Number) & ")" End If WScript.Quit 1 End If On Error Goto 0
Set wb = Nothing For Each obj In xl.Workbooks If obj.Name = ExcelFileName Then 'use obj.FullName for full path Set wb = obj WScript.Echo "Workbook is OPEN - OK" Exit For End If Next
If wb Is Nothing Then WScript.Echo "Workbook not open." WScript.Quit 1 End If
|
Source:
|
|
pus acum 3 ani |
|
Mrrrr
AdMiN
Inregistrat: acum 18 ani
Postari: 2241
|
|
Added the part in color for the case when the Excel application is not open.
_______________________________________
|
|
pus acum 1 an |
|