Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
rci rci is offline
external usenet poster
 
Posts: 40
Default Fancy Object Declaration



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
  #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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array Declaration. apis Excel Discussion (Misc queries) 1 November 5th 11 01:53 PM
Workbook Declaration Varne Excel Discussion (Misc queries) 3 April 29th 08 09:49 AM
fancy lookup strawberry Excel Worksheet Functions 4 March 1st 06 05:09 PM
Need to do a fancy string copy plus Sally Excel Discussion (Misc queries) 7 November 4th 05 02:06 PM
Declaration? TJF[_2_] Excel Programming 5 December 18th 03 03:26 PM


All times are GMT +1. The time now is 07:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"