PDA

View Full Version : Solved: application/object defined error when .IsAddin is true, but not false



tpoynton
08-14-2007, 06:39 AM
Greetings - not able to figure out why this line errors out when thisworkbook.isaddin is set to true, but works when thisworkbook.isaddin is false.

ThisWorkbook.Sheets("lngTrsl8").Range(Cells(1, 2), Cells(1, 2).End(xlToRight))

This is the sheet that is not visible when .isaddin is set to true...is that it? I'm able to pull cell values from this sheet without any problem when the sheet is not visible, but this is my first time trying to do anything with a range (populating a combobox).

Bob Phillips
08-14-2007, 06:55 AM
Tim,

It is nothing (specifically) to do with the addin, it is because the objects aren't fully qualified. Setting IsAddin to true was hust the trigger that shows it here

You should use



With ThisWorkbook.Sheets("lngTrsl8")
Set rng = .Range(.Cells(1, 2), .Cells(1, 2).End(xlToRight))
End With


Note the .Cells, not Cells. Cells will point at the activesheet. not necessarily the one that you want.

Bob Phillips
08-14-2007, 06:58 AM
Tim,

It is nothing (specifically) to do with the addin, it is because the objects aren't fully qualified. Setting IsAddin to true was just the trigger that shows it here

You should use



With ThisWorkbook.Sheets("lngTrsl8")
Set rng = .Range(.Cells(1, 2), .Cells(1, 2).End(xlToRight))
End With


Note the .Cells, not Cells. Cells will point at the activesheet. not necessarily the one that you want.[/QUOTE]

tpoynton
08-14-2007, 07:20 AM
Aha - thank you Bob! Not only for the solution, but the explanation. I've seen the .Cells thing before...but never knew why to use it.

I have encountered this sort of thing before, now that I understand the problem is not with the isaddin property...my previous solution? activating the worksheet. This helps me tremendously - thank you:bow: