Results 1 to 3 of 3

Thread: Excel in VBScript *RESOLVED*

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    4

    Post Excel in VBScript *RESOLVED*

    Hi

    I'm trying to use vbscript to do some excel formatting. I'm using late binding within vbscript and have figured out how to write parameters after excel methods/properties using the Const value.
    e.g.
    .ActiveWorkbook.SaveAS "filename", -4143

    However, I am having trouble with moving an excel worksheet within an open workbook. The VBA code is similair to this:

    Sheets("Sheet2").Select
    Sheets("Sheet2").Move Before:=Sheets(1)

    Does anyone know what the code shouldlook like in VBScript - it's the Before part that is giving me trouble.

    many thanks
    Last edited by R00tj00se1; Oct 14th, 2003 at 04:12 AM.

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    You don't need the "Before:=" part because the first parameter after Move if the Before value. Also, you don't need to select the sheet before moving it. VBScript may also want to have the Sheet prefaced by a Workbook. Try this:

    VB Code:
    1. ActiveWorkbook.Sheets("Sheet2").Move ActiveWorkbook.Sheets(1)

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    4
    Thanks WorkHorse - I should have been able to work this out but I think my brain was fried. Your answer pointed me in the right direction. Instead of:

    ActiveWorkbook.Sheets("Sheet2").Move ActiveWorkbook.Sheets(1)

    vbscript seems to want:
    With oxl
    ActiveWorkbook.Sheets("Sheet2").Move oxl.ActiveWorkbook.Sheets(1)
    End with

    (where oxl is the reference to the excel object)
    The parameter has to have oxl. otherwise vbscript thinks ActiveWorkBook is a variable.

    many thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width