Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Using VB6.0, created an .exe file that fronts end access to programmes - VB6
used to gain ther functionality not available in Excel. Need to check if specific Excel programmes are open to avoid attempting to re-open |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
By <check if specific Excel programmes are open do you mean check
whether specific workbooks (including AddIns) are open within an Excel instance or do you just mean check for Excel instances? In the below example the procedure Test, tries to open an Excel instance using fcnOpenExcelInstance (you may want to change this so that it doesn't open an instance if there isn't one already open). Then Test passes the Excel instance to a function called fcnCheckForOpenWorkbooks along with a string of the workbook-to-be-checked's name which checks whether that workbook is already open. HTH, Gareth Sub Test() Dim oXL as object set oXL = fcnOpenExcelInstance if oXL = nothing then msgbox "couldn't open Excel" end if if fcnCheckForOpenWorkbooks (oXL, "Book1.xls") msgbox "Book1.xls is open" end if End Sub Function fcnCheckForOpenWorkbooks(XL as object, WBName as string) _ as boolean Dim wb as object for each wb in XL.workbooks if lcase(wb.name) = lcase(WBname) then 'note, you might like to check against FullName rather than 'just name - that's why I'm using a loop here rather than 'something non-looping using error trapping fcnCheckForOpenWorkbooks= true end if next wb End Function Function fcnOpenExcelInstance() as object Dim oXL As Object 'get existing instance of Excel On Error Resume Next Set oXL = GetObject(, "Excel.Application") On Error GoTo 0 'were we successful If oXL Is Nothing Then 'create new instance On Error Resume Next Set oXL = CreateObject("Excel.Application") On Error GoTo 0 End If 'check we were successful If not oXL Is Nothing Then 'you might not need/want this line oXL.Visible = True set fcnOpenExcelInstance= oXL End If Set oXL = Nothing End Function Graham Masters wrote: Using VB6.0, created an .exe file that fronts end access to programmes - VB6 used to gain ther functionality not available in Excel. Need to check if specific Excel programmes are open to avoid attempting to re-open |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
can anyone tell me how to set excel to open to a specific folder | Excel Discussion (Misc queries) | |||
How can I insert a check box into a specific cell in Excel? | Excel Discussion (Misc queries) | |||
execl to check if another excel file is open... | Excel Programming | |||
How to check for an open Network connection in Excel VBA? | Excel Programming | |||
How to check Excel file already Open | Excel Programming |