Results 1 to 4 of 4

Set dest = Workbooks.Add(xlWBATWorksheet)-What is this?

This is a discussion on Set dest = Workbooks.Add(xlWBATWorksheet)-What is this? within the Excel Questions forums, part of the Question Forums category; I am pulling my hair out over this string as I keep getting a run time error because of it, ...

  1. #1
    Board Regular
    Join Date
    Oct 2003
    Location
    USA
    Posts
    301

    Default Set dest = Workbooks.Add(xlWBATWorksheet)-What is this?

    I am pulling my hair out over this string as I keep getting a run time error because of it, anyone know what this line means?

  2. #2
    dk
    dk is offline
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,934

    Default Re: Set dest = Workbooks.Add(xlWBATWorksheet)-What is this?

    Hi,

    It adds a new workbook with a single worksheet in it and sets the variable dest so that from then on it will refer to that newly added workbook e.g. you could then use:-

    Code:
    Sub test()
    Dim dest As Workbook
    
    Set dest = Workbooks.Add(xlWBATWorksheet)
    
    dest.SaveAs "D:\some folder\my file.xls"
    End Sub

    Anyway, what is the error message you're getting?

    Dan

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,950

    Default Re: Set dest = Workbooks.Add(xlWBATWorksheet)-What is this?

    FWIW,

    You can use a shorter, and in my opinion, one that makes more sense, constant:

    Code:
    Set dest = Workbooks.Add(xlWorksheet)
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  4. #4
    Board Regular
    Join Date
    Oct 2003
    Location
    USA
    Posts
    301

    Default Re: Set dest = Workbooks.Add(xlWBATWorksheet)-What is this?

    actually I wanted to just take that bit of code out, I dont want it to save anything or do anything but e-mail me when someone made a change. Thanks guys

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com