Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
Works fine in xl2000
"Chris" wrote: 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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
Doug, thanks for checkiing it in xl03. After reading your results and
everyone elses, I went back and tried and failed again (something has to be wrong). Then I tried it in a new xl '03 workbook and it worked fine. All I can figure is that there was something incompatible in the workbook I was originally trying it in. It was an old workbook that had its origin in xl '95 but had been saved to newer formats as my xl was upgraded. It had been working fine with other '03 features till this little quirk appeared. Thanks to all. "Doug Glancy" wrote: 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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
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 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
I can get that error if I don't have a valid constant value in the first
argument. I would suggest you edited the macro and (inadvertently) changed the first argument from something other than msoShapeRectangle or you redefined the value of msoShapeRectangle. -- Regards, Tom Ogilvy "Chris S." wrote in message ... Doug, thanks for checkiing it in xl03. After reading your results and everyone elses, I went back and tried and failed again (something has to be wrong). Then I tried it in a new xl '03 workbook and it worked fine. All I can figure is that there was something incompatible in the workbook I was originally trying it in. It was an old workbook that had its origin in xl '95 but had been saved to newer formats as my xl was upgraded. It had been working fine with other '03 features till this little quirk appeared. Thanks to all. "Doug Glancy" wrote: 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 |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
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 |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
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 |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
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 |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
I've experienced the same difficulties and having followed the thead of
postings here, I have found them to be EXTEMELY helpful. Thank you all for your contributions!! "Jim Thomlinson" wrote: Works fine in xl2000 "Chris" wrote: 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 |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error '1004' - the specified value is out of range.
This has just solved a problem that I have spent two solid days trying
to resolve. Many thanks! *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Range Question / error 1004: method Range of object Worksheet has failed | Excel Programming | |||
Set worksheet range runtime error 1004 | Excel Programming | |||
1004 error when selecting a range | Excel Programming | |||
Error 1004 when selecting a range | Excel Programming | |||
Range.Copy and error 1004 | Excel Programming |