Results 1 to 3 of 3

Thread: GetObject {Resolved}

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    4

    Resolved GetObject {Resolved}

    I have created a dll in VB 6.0. I am using the GetObject method to get the path of the excel file that called the dll. However, I have just realized that if there are two different excel files open, this will return the first file path that was opened, not necessarily the file that called the dll. Is there another method that I can use...like GetThisObject, or something similar?

    Below is an example of what I am using.


    Dim ExcelTest As Excel.Application

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


    In addition, when I try to use this method in a simular method in Access 97, I get a "Run-Time Error '429': ActiveX component can't create object" error. However, this will work in Access 2000.

    The code being used for the Access application is

    Dim AccessTest As Access.Application

    Set AccessTest = GetObject(, "Access.Application")


    Any ideas??

    Thanks!
    Last edited by thedude1972; Jan 24th, 2005 at 04:30 PM.

  2. #2
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: GetObject

    Quote Originally Posted by thedude1972
    I have created a dll in VB 6.0. I am using the GetObject method to get the path of the excel file that called the dll. However, I have just realized that if there are two different excel files open, this will return the first file path that was opened, not necessarily the file that called the dll. Is there another method that I can use...like GetThisObject, or something similar?

    Below is an example of what I am using.


    Dim ExcelTest As Excel.Application

    Set ExcelTest = GetObject(, "Excel.Application")
    The code above will only get you the application, and is probably either giving you the first window that Excel has open, or the currently active workbook. Once you get your Excel object, you need to switch workbooks, something like:

    VB Code:
    1. Dim oExcelBook As Excel.Workbook
    2. Set oExcelBook = ExcelTest.Workbooks("MyBook.xls")
    If you aren't sure if it will be open, you can enumerate open workbooks too, like:
    VB Code:
    1. Dim oExcelBook As Excel.Workbook
    2. Dim oLookinFor As Excel.Workbook
    3.  
    4. For Each oExcelBook In ExcelTest.Workbooks
    5.     If oExcelBook.Name = "MyBook.xls" Then
    6.         Set oLookinFor = oExcelBook
    7.         Exit For
    8.     End If
    9. Next oExcelBook

  3. #3
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: GetObject

    I don't think Access97 was designed to be used as an ActiveX Object the way Access2000 is.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width