+ Reply to Thread
Results 1 to 8 of 8

Debug this?

  1. #1
    Registered User
    Join Date
    10-14-2003
    Posts
    7

    Debug this?

    This line:

    Set wksA = gwbB.Names("aName").RefersToRange.Parent

    produces the 1004 Application or object defined error in my program, and I can`t figure out why. The statement resides in an addin and tries to set a reference to a sheet (in another project) with a range referred to by the name aName.

    wksA is local to the sub in which the error occurs. wksA is declared as

    Dim wksA as Worksheet

    Debug.print gwkbB.Name shows me the name of the project is correct and the project certainly has the name aName in it and it refers to a range ok.

    Could it be that one needs to set a reference to some special object library to do this?

    Any help is much appreciated.
    Last edited by hke; 05-11-2005 at 09:04 AM. Reason: Added more info

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Hke,

    The error occurrs because you are attempting to set a Worksheet object equal to a Range object. It like Apples and Oranges. When using Set both objects must be the same or you get the error.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    10-14-2003
    Posts
    7
    thanks for your reply
    very well. How then, do you set a sheet variable to refer to a sheet in project, gwbkB, knowing the name of a range on that sheet

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Hke,

    This should work.

    WksB = gwbB.Names("aName").RefersToRange.Parent.Name
    Set wksA = gwbB.Worksheets(WksB)


    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    10-14-2003
    Posts
    7
    I still get the 1004 error on that first line of code.

    debug.print gwbB.Names("aName").RefersToRange.Parent.Name

    also makes a 1004

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Hke,

    Check if WksB contains the Workbook name as well as the Worksheet name by placing a breakpoint in the code next to Set.

    Let know,
    Leith Ross

  7. #7
    Registered User
    Join Date
    10-14-2003
    Posts
    7
    Again, thanks for your effort Leith

    wksB equals Nothing. It is the first line ,

    wksB = gwbB.Names("aName").RefersToRange.Parent.Name

    , that makes the 1004 happen.

    Could a language incompatibility cause this conflict? I suspect this because the names of the sheets in gwbB are displayed as

    "Sheet1 (Sheet1name)"

    in the project browser. However, if do a Sheets.Add in some other project I get the norwegian

    "Ark1(Ark1)"

    in the browser.
    Last edited by hke; 05-11-2005 at 11:06 AM.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Hke,

    That is certainly a possibility. I didn't realize that this was a multi-lingual setup. Unfortunately, I don't know if or how the code pages could be manipulated to make this work. If you will be using workbooks in both langauges this could be a major obstalce with no easy solutions. Sorry I don't have any other ideas.

    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1