View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Chris S.[_2_] Chris S.[_2_] is offline
external usenet poster
 
Posts: 6
Default Error '1004' - the specified value is out of range.

Eureka Tom, you are the master! That the constant, 'msoShapeRectangle',
wasn't being recognized had to mean that the library identifying that
constant wasn't being accessed.

When I did what you suggested in your post, I found that the 'MS Office 11
Object Library' was missing from the list in my old workbook. I selected it
to add it to the reference list and then ran the macro. It WORKED PERFECTLY!

Thank you for identifying the problem and working me through the fix....

"Tom Ogilvy" wrote:

You need to go into tools=References in the VBE and create a reference to
the office library. That library is where the constant is defined. Since
it appears you don't have a reference, the constant evaluated to Zero, the
same situation I hypothesized if the constant name was misspelled.

To see which reference, make your "new" workbook the activeproject and then
look in tools=references. You will see you have a reference to the office
type library there. Make your "old" workbook have the same set of
references (the activeproject is the one that is selected in the project
window - when you do Tools=References, you are looking at the reference
list for the activeproject).

--
Regards,
Tom Ogilvy

"Chris S." wrote in message
...
Here's a new twist. When I copied the working macro from the vbmodule in

the
new workbook to a module in my original, I get a runtime error which is
different. Now it highlights 'msoShapeRectangle' and notes that 'variable

is
undefined'. There is something about my original workbook that it can't
recognize these 'msoShape' constants.

This is what I tried next. With both workbooks open and a worksheet from

my
problematic original workbook as the 'activesheet', I tried running the

macro
using the macro command from the tools menu. But this time I selected the
(identical) macro that was stored in the vb module in the new xl 03

workbook.
This time it worked fine, but it won't work with the code stored in the
module in its own workbook.....

"Chris S." wrote:

This is baffling to me that I can't get it to work in my original

workbook.
Tom Ogilvy suggested that I may have inadvertently changed the constant
'msoShapeRectangle' , but that is not the case because I try running the
macro right after stopping the 'record macro' process and then get the
runtime error. I get the same error when I record making an oval.

When I go through the same exact record process in a new xl 03 workbook,

the
macros work fine.

When I compare the code from the two workbooks, it is absolutely

identical.

If I copy the working macro from the new workbook into my original, I

get
the runtime error. What gives?

Thanks for checking into it.

"Don Guillett" wrote:

I have xl95,xl97 and xl2002. So, I went to xl95 and created a

workbook. I
then went to xl2002 and added the macro
sub dd
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 46.5, 43.5, 316.5,
240#).Select
end sub
and it worked fine in a regular module, in a sheet module and in
ThisWorkbook.
Corruption???


--
Don Guillett
SalesAid Software

"Doug Glancy" wrote in message
...
Chris,

This is what I record in XL 03. It works when I run it:

ActiveSheet.Shapes.AddShape(msoShapeRectangle, 46.5, 43.5,

316.5,
240#).
_
Select

I also ran your exact code and it worked.

Doug

"Chris S." wrote in message
...
Don, thanks for checking it out. Did xl2002 generate the same

line of
code
during the record process? This is absolutely maddening to me

because I
can't get the macro to run for making rectangles or ovals in

xl2003.
Are
there any xl2003 users out there who could try the record process.

"Don Guillett" wrote:

I just tested this in a regular module in xl2002 and it worked

fine.

--
Don Guillett
SalesAid Software

"Chris" <Chris wrote in message
...
Could someone please enlighten me as to why I get a runtime

error
from
this
line of code. It was generated by Excel 2003 itself using the
'record
macro'
command from the 'tools menu'. I selected 'record', then the
rectangle
shape
from the drawing tools menu, then dragged my cursor in the

upper
left
corner
of my worksheet to the approx. size rectangle I wanted, then

stopped
recording. When I try to run the macro, I get "Runtime error
'1004' -
the
specified value is out of range." I appreciate any response.

I
Sub Macro1()
'
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 18#, 18#,

108#,
41.25). _
Select
End Sub