Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 257
Default "Object not set"?

I'm still learning about scope and visibility of objects, but
I thought I had a general handle on the concept. This
problem, though, has me stonkered:

In a sheet module, declarations section:
Public wbo

The same sheet module, the first procedure, the
first two statements:
Set wbo = Workbooks("MyWorkbook.xls")
Stns = RangeValues("Map", 2, 4)

RangeValues is in a separate module named "Common".
It starts out like this:
Function RangeValues(SheetName, RowA, ColZ)
Set wso = wbo.Worksheets(SheetName)

So we enter RangeValues with the first argument set
to "Map", and when it gets to the statement "Set
wso=wbo.Worksheets(Sheet)" I expect it to set wso to
the worksheet named "Map". Instead I get an error 91:

Run-time error '91':
Object variable or With block variable not set.

This SEEMS to say that wbo isn't properly initialized as a
workbook object. Yet just before it executes the Set statement
I can see wbo in the Watch window, with the Map sheet as one
of its properties. So is the error message talking about some
other object? Can anyone see the obvious piece I'm missing?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default "Object not set"?

Check your other post.

Bob Bridges wrote:

I'm still learning about scope and visibility of objects, but
I thought I had a general handle on the concept. This
problem, though, has me stonkered:

In a sheet module, declarations section:
Public wbo

The same sheet module, the first procedure, the
first two statements:
Set wbo = Workbooks("MyWorkbook.xls")
Stns = RangeValues("Map", 2, 4)

RangeValues is in a separate module named "Common".
It starts out like this:
Function RangeValues(SheetName, RowA, ColZ)
Set wso = wbo.Worksheets(SheetName)

So we enter RangeValues with the first argument set
to "Map", and when it gets to the statement "Set
wso=wbo.Worksheets(Sheet)" I expect it to set wso to
the worksheet named "Map". Instead I get an error 91:

Run-time error '91':
Object variable or With block variable not set.

This SEEMS to say that wbo isn't properly initialized as a
workbook object. Yet just before it executes the Set statement
I can see wbo in the Watch window, with the Map sheet as one
of its properties. So is the error message talking about some
other object? Can anyone see the obvious piece I'm missing?


--

Dave Peterson
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
why do i "sometimes" need to "edit chart object" before "source da Flirty and Blonde Charts and Charting in Excel 1 February 2nd 10 02:07 PM
method "range" of object "_worksheet" fails PBcorn Excel Programming 5 October 27th 08 04:33 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Error Help - Method "Range" of object "_Worksheet" failed. Alan Smith Excel Programming 3 March 15th 07 06:55 PM
What is Error "Method "Paste" of object "_Worksheet" failed? vat Excel Programming 7 February 17th 06 08:05 PM


All times are GMT +1. The time now is 03:30 AM.

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"