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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amolbehl
    New Member
    • May 2007
    • 63

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

    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.

    Code:
    Set oXL = CreateObject("Excel.Application")
        oXL.Visible = True
        Set oWB = oXL.Workbooks.Add
        oWB.Windows.Application.Visible = true
        Set oSheet = oWB.ActiveSheet
        oSheet.Name = "TEST"
        oSheet.Visible = xlSheetVisible
        
        Dim left As Single
        Dim top As Single
        Dim wide As Single
        Dim height As Single
        
        left = 100
        top = 100
        wide = 100
        height = 100
            
        oSheet.Shapes.AddShape msoShapeRectangle, left, top, wide, height
    Can anyone help me to solve this error.

    What are the appropriate values for left,top and wide and height?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    please run in debug mode and check whick line is creating the errror.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      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.)

      Comment

      Working...