Connecting Tech Pros Worldwide Forums | Help | Site Map

Runtime Error '1004' - Specified value is out of range.

Member
 
Join Date: May 2007
Posts: 63
#1: Jan 12 '08
I use VB6.0 and when I execute the code I have given below, I get runtime Error 1004 - Specified value is out of range.

Expand|Select|Wrap|Line Numbers
  1. Set oXL = CreateObject("Excel.Application")
  2.     oXL.Visible = True
  3.     Set oWB = oXL.Workbooks.Add
  4.     oWB.Windows.Application.Visible = true
  5.     Set oSheet = oWB.ActiveSheet
  6.     oSheet.Name = "TEST"
  7.     oSheet.Visible = xlSheetVisible
  8.  
  9.     Dim left As Single
  10.     Dim top As Single
  11.     Dim wide As Single
  12.     Dim height As Single
  13.  
  14.     left = 100
  15.     top = 100
  16.     wide = 100
  17.     height = 100
  18.  
  19.     oSheet.Shapes.AddShape msoShapeRectangle, left, top, wide, height
  20.  
Can anyone help me to solve this error.

What are the appropriate values for left,top and wide and height?

debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,508
#2: Jan 12 '08

re: Runtime Error '1004' - Specified value is out of range.


please run in debug mode and check whick line is creating the errror.
Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#3: Jan 13 '08

re: Runtime Error '1004' - Specified value is out of range.


amolbehl, I recommend you avoid using the names top, left or height for variables. These are the names of commonly used properties of various controls, and may cause confusion.

(Probably not related to this specific problem, though.)
Reply