Add a check box to an excel spreadsheet using VB Script

Author Message
shimon

  • Total Posts : 3
  • Scores: 0
  • Reward points : 0
  • Joined: 10/26/2010
  • Status: offline
Add a check box to an excel spreadsheet using VB Script Tuesday, October 26, 2010 8:06 AM (permalink)
0
Hello,
 
I have a script that creates a Excel file, I wanted to add a check box to on of the cells. I get an error message:
Error:   Wrong number of arguments or invalid property assignment: 'Left'
Code:   800A01C2
 
From this code:
[xlBook.ActiveSheet.OLEObjects.Add ClassType="Forms.CheckBox.1", Link=False, _
DisplayAsIcon=False, Left=Range("A1").Left, _
Top=Range("A1").Top, Width=108, Height=19.5[/code]
 
[[<font][<font]Best Regards
 
#1
    ehvbs

    • Total Posts : 3320
    • Scores: 112
    • Reward points : 0
    • Joined: 6/22/2005
    • Location: Germany
    • Status: offline
    Re:Add a check box to an excel spreadsheet using VB Script Tuesday, October 26, 2010 8:25 AM (permalink)
    0
    You can't use named arguments (like ClassType:="...") in VBScript;
    replace them with positional ones.
    (BTW: Thank you for this "useful" "completed VBScript")
     
     
    #2
      shimon

      • Total Posts : 3
      • Scores: 0
      • Reward points : 0
      • Joined: 10/26/2010
      • Status: offline
      Re:Add a check box to an excel spreadsheet using VB Script Wednesday, October 27, 2010 5:06 AM (permalink)
      0
      ehvbs


      You can't use named arguments (like ClassType:="...") in VBScript;
      replace them with positional ones.
      (BTW: Thank you for this "useful" "completed VBScript")



      e

       
      Thank you so much For point me in the right direction. Here is the working Code:
       
      [ xlBook.ActiveSheet.OLEObjects.Add "Forms.CheckBox.1"
      With xlBook.ActiveSheet.OLEObjects
      .Left = 50
      .Top = 10
      .Width = 100
      .Height = 15
      End with [/code]
       

       
      #3
        shimon

        • Total Posts : 3
        • Scores: 0
        • Reward points : 0
        • Joined: 10/26/2010
        • Status: offline
        Re:Add a check box to an excel spreadsheet using VB Script Wednesday, October 27, 2010 5:09 AM (permalink)
        0
        to EHVBS
         
        Both days my comments were cut off after I entered the Code, I also added Thank you I appreciate your input and support.
         
        Best regards,
         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9