Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting data to an already open Excel Workbook 2

Status
Not open for further replies.

ActMod

Technical User
Aug 25, 2003
45
US
vbslammer was very helpful in providing the code that enabled me to open a closed Excel Workbook. Now I need to export data from Access to an already open Excel Workbook. I can't figure out how to get Access to find all open Excel Workbooks. Is there a way to sort through all open Excel Workbooks to find a particular one to which data can be exported?

Thank you for any help.
 
G'day,

If you want to find out if an Excel app is already opened try this:

Set XLApp = GetObject(, "Excel.Application")

Then check if there is an instance already opened, eg:

If XLApp <> Nothing Then
<<enter code>>

Activate the Excel app and manipulate it from there.
Any questions don't hesitate to ask
 
As a next step, if you want to find a particular workbook from several open ones, assuming they are all in the same instance of excel you will need to step through them.

Dim XLApp as Excel.Application
Dim WB As Excel.Workbook

Set XLApp = GetObject(, &quot;Excel.Application&quot;)
for Each WB in XLApp.Workbooks
if WB.Name=&quot;G:\XL\MyBook.xls&quot; then
Code:
   end if
next WB

hth

Ben

----------------------------------------------
Ben O'Hara
[URL unfurl="true"]www.RobotParade.co.uk[/URL]

&quot;Where are all the stupid people from...
...And how'd they get so dumb?&quot;
                        [i]NoFX-The Decline[/i]
----------------------------------------------
 
Thanks much to both JunglesMcBeef and oharab for helpful suggestions. The macro seems to work but it doesn't find my open Excel workbook. I guess because it is not in the &quot;instance&quot; that the macro is searching. Assuming that is the problem, is there anyway to find and search through all open instances or some other workaround to the problem?

Thanks again.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top