[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference abbott::visual_basic

Title:Microsoft Visual Basic
Moderator:TAMARA::DFEDOR::fedor
Created:Thu May 02 1991
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2565
Total number of notes:10453

2491.0. "Problem setting up OLE application link" by ALLVAX::LI () Thu Feb 06 1997 11:42

    The problem is as follows:
    
    I have set up an OLE link with an existing Microsoft Excel application
    (one instance of Microsoft Excel running) on my VB program using
    GETOBJECT(, "EXCEL.APPLICATION"). It works fine. However, if I have two
    instances of Microsoft Excel running simultaneously how can I make OLE
    link with a particular one. It seems to me that it always make link with
    the first one. What if I want to link with the second instance?
    
    Any solution or suggestion is welcome. Thanks in advance.
T.RTitleUserPersonal
Name
DateLines
2491.1Use CreateObject() to be sure ...FUTURS::MARSHALL1Mon Feb 17 1997 04:3320
    
    I remember playing around with the OLE autometion interface from VB to
    Excel and had a lot of fun (NOT)!
    
    I do not believe that if you have multiple instances of Excel running
    that you *can* specify which on it is connecting to. All windows does
    is to locate an 'Excel.Application' object and connect you to that. It
    is random which one you will get too. There is *ABSOLUTELY NO
    GUARANTEE* which of the running objects you will connect to.
    
    There is hope though. The way that I solved the problem was to always 
    create my own instance of the Excel object via the CreateObject() call
    and to that open and manipulate the workbooks that I needed. I then
    closed down my instance of the Excel object when I was finished.
    
    I found no other way of being sure ...
    
    	Steve.