ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping Through Every Instance of Excel (https://www.excelbanter.com/excel-programming/384526-looping-through-every-instance-excel.html)

[email protected]

Looping Through Every Instance of Excel
 
Hello,
I want to loop through every instance of excel and find an open
workbook, I tried this:

For i = 1 To app.workbooks.Count + 1
z = app.workbooks(i).Name
If InStr(app.workbooks(i).Name, "STXL") Then
WB_Found = True
Exit For
End If
Next

Unfortunately, this only finds the open workbooks within each
individual instance. Is this even possible?

Clay


Tom Ogilvy

Looping Through Every Instance of Excel
 
some have suggested:

set xlapp=getobject(,"fully qualified workbookname").Parent

--
Regards,
Tom Ogilvy

" wrote:

Hello,
I want to loop through every instance of excel and find an open
workbook, I tried this:

For i = 1 To app.workbooks.Count + 1
z = app.workbooks(i).Name
If InStr(app.workbooks(i).Name, "STXL") Then
WB_Found = True
Exit For
End If
Next

Unfortunately, this only finds the open workbooks within each
individual instance. Is this even possible?

Clay



[email protected]

Looping Through Every Instance of Excel
 
On Mar 5, 9:17 am, Tom Ogilvy
wrote:
some have suggested:

set xlapp=getobject(,"fully qualified workbookname").Parent

--
Regards,
Tom Ogilvy



" wrote:
Hello,
I want to loop through every instance of excel and find an open
workbook, I tried this:


For i = 1 To app.workbooks.Count + 1
z = app.workbooks(i).Name
If InStr(app.workbooks(i).Name, "STXL") Then
WB_Found = True
Exit For
End If
Next


Unfortunately, this only finds the open workbooks within each
individual instance. Is this even possible?


Clay- Hide quoted text -


- Show quoted text -


I don't know the name of the excel workbook, only that the name
contains "STXL".


NickHK

Looping Through Every Instance of Excel
 
Maybe this will get you started:
http://vbnet.mvps.org/code/system/fi...likesimple.htm

Peter T has a some posts on this subject in this NG. Search through Google.

NickHK

wrote in message
ups.com...
On Mar 5, 9:17 am, Tom Ogilvy
wrote:
some have suggested:

set xlapp=getobject(,"fully qualified workbookname").Parent

--
Regards,
Tom Ogilvy



" wrote:
Hello,
I want to loop through every instance of excel and find an open
workbook, I tried this:


For i = 1 To app.workbooks.Count + 1
z = app.workbooks(i).Name
If InStr(app.workbooks(i).Name, "STXL") Then
WB_Found = True
Exit For
End If
Next


Unfortunately, this only finds the open workbooks within each
individual instance. Is this even possible?


Clay- Hide quoted text -


- Show quoted text -


I don't know the name of the excel workbook, only that the name
contains "STXL".




Peter T

Looping Through Every Instance of Excel
 
Yes I have described how I do it once or twice!

Recently in this ng Rama posted a link to this approach to populate a
collection of Excel instances which works very well indeed -
http://www.mrexcel.com/board2/viewto...37277&start=10

As written it doesn't necessarily catch all instances, in contrast to my
rather more clunky method which normally does.

Regards,
Peter T

"NickHK" wrote in message
...
Maybe this will get you started:
http://vbnet.mvps.org/code/system/fi...likesimple.htm

Peter T has a some posts on this subject in this NG. Search through

Google.

NickHK

wrote in message
ups.com...
On Mar 5, 9:17 am, Tom Ogilvy
wrote:
some have suggested:

set xlapp=getobject(,"fully qualified workbookname").Parent

--
Regards,
Tom Ogilvy



" wrote:
Hello,
I want to loop through every instance of excel and find an open
workbook, I tried this:

For i = 1 To app.workbooks.Count + 1
z = app.workbooks(i).Name
If InStr(app.workbooks(i).Name, "STXL") Then
WB_Found = True
Exit For
End If
Next

Unfortunately, this only finds the open workbooks within each
individual instance. Is this even possible?

Clay- Hide quoted text -

- Show quoted text -


I don't know the name of the excel workbook, only that the name
contains "STXL".






[email protected]

Looping Through Every Instance of Excel
 
On Mar 6, 4:45 am, "Peter T" <peter_t@discussions wrote:
Yes I have described how I do it once or twice!

Recently in this ng Rama posted a link to this approach to populate a
collection of Excel instances which works very well indeed -http://www.mrexcel.com/board2/viewtopic.php?t=237277&start=10

As written it doesn't necessarily catch all instances, in contrast to my
rather more clunky method which normally does.

Regards,
Peter T

"NickHK" wrote in message

...



Maybe this will get you started:
http://vbnet.mvps.org/code/system/fi...likesimple.htm


Peter T has a some posts on this subject in this NG. Search through

Google.

NickHK


wrote in message
oups.com...
On Mar 5, 9:17 am, Tom Ogilvy
wrote:
some have suggested:


set xlapp=getobject(,"fully qualified workbookname").Parent


--
Regards,
Tom Ogilvy


" wrote:
Hello,
I want to loop through every instance of excel and find an open
workbook, I tried this:


For i = 1 To app.workbooks.Count + 1
z = app.workbooks(i).Name
If InStr(app.workbooks(i).Name, "STXL") Then
WB_Found = True
Exit For
End If
Next


Unfortunately, this only finds the open workbooks within each
individual instance. Is this even possible?


Clay- Hide quoted text -


- Show quoted text -


I don't know the name of the excel workbook, only that the name
contains "STXL".- Hide quoted text -


- Show quoted text -


Thanks everyone this is very helpful.



All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com