Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Multiple instances of Excel and VB

I am using VB6 and Excel 97.

I have a problem where if the is an instance of Excel is open with an
open workbook. And I try to do OLE Automation, then the data from one
report, ends up on the spreadsheet that happened to be open at the
time.

What can I do so that when I dump data into a spreadsheet, it will not
disturb other instances of Excel.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Multiple instances of Excel and VB

"Rich" wrote in message
om...
I am using VB6 and Excel 97.

I have a problem where if the is an instance of Excel is open with an
open workbook. And I try to do OLE Automation, then the data from one
report, ends up on the spreadsheet that happened to be open at the
time.

What can I do so that when I dump data into a spreadsheet, it will not
disturb other instances of Excel.


Hi Rich,

You need to create your own separate instance of Excel and use that
instance to do whatever it is you need to do. Something along the lines of
(not tested):

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Add ''' .Open for an exisiting workbook
Set xlSheet = xlBook.Worksheets(1)

''' Create your report on xlSheet. Be sure to qualify all object
''' references on xlSheet with the xlSheet variable.

xlBook.SaveAs "C:\Files\MyBook.xls" ''' just .Save for an existing workbook

Set xlSheet = Nothing
xlBook.Close False
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Multiple instances of Excel and VB

Keeping track of worksheet names is a good idea if your doing this with code.
Create string variables for various sheets, when you know one is opem in the
code, populate the variable with that name then you can refer to various
workbooks like

workbooks(var1).activate
sheets(1).cells.select
workbooks(var2).activate
selection.paste

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple instances of Excel (Multiple workbooks) Shane Setting up and Configuration of Excel 3 November 13th 09 05:07 PM
Using RTD with multiple instances of excel [email protected] Excel Discussion (Misc queries) 0 February 13th 09 10:51 AM
Multiple Instances of EXCEL.EXE MKG Excel Discussion (Misc queries) 3 February 3rd 07 12:08 AM
Multiple Instances of Excel David Z Excel Discussion (Misc queries) 18 July 1st 06 02:26 PM
Multiple instances of Excel Carol Crowley Excel Discussion (Misc queries) 9 March 17th 06 06:18 PM


All times are GMT +1. The time now is 01:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"