View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
rci rci is offline
external usenet poster
 
Posts: 40
Default Fancy Object Declaration

rci wrote:


Belay that...

I discovered the TypeName() method of determining the exact object.

Best regards,

Mike


: Hi all...

: I cut my teeth on code with line numbers and goto statements... so all
: this newfangled object stuff is mind bending.

: Current issue: Trying to be good be explicit object declaration.

: My reward for trying to be good by declaring objects explicitly is that in
: some cases, where code USED to work (because VBA was smart enough to handle
: things without declaration) I now don't, in all cases, know what the heck
: object was created...

: Example:

: MyFunction()

: Dim oChart

: Set oChart = ChartSpace1.Charts(0)

: End Function



: ...used to be just dandy

: ...now: Substitute "Best Guess" with many different object types

: Public oChart as "Best Guess"
: -----------------------------------------------------

: MyFunction()

: Set oChart = ChartSpace1.Charts(0)

: End Function

: chokes because my "best guess" as to what the object is suppossed to be is
: always wrong.

: Type mispatch error.

: How do I discover what ChartSpace1.Charts(0) is trying to create? Since VBA
: apparently knows what this is... (because it is aware of the mismatch) I
: wonder why the Error message fails to say?

: Anyway, advice on declaring this properly is very much appreciated.

: Thanks,

: Mike