+ Reply to Thread
Results 1 to 2 of 2

Return type of function Workbooks.Add

  1. #1
    Forum Contributor
    Join Date
    04-09-2013
    Location
    City, World
    MS-Off Ver
    Office 365
    Posts
    248

    Return type of function Workbooks.Add

    Hi
    In the object browser, workbooks.add function define as this

    Function Add([Template]) As Workbook

    The part I do not understand is "As Workbook"? What does that mean? Does that mean function add is an object of type Workbook? and that is why we can say this

    Please Login or Register  to view this content.
    Thank you.
    Last edited by 6StringJazzer; 02-25-2021 at 09:00 AM. Reason: Please use better titles!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Return type of function Workbooks.Add

    It means that Add is a Function. A Function returns a value of some type, and in this case it returns a Workbook object. So you can treat a call to that function as if it were a Workbook object.

    That is why your code works. I would not use the code that you showed because you create a new workbook which remains open, save it, and then do not have a handle to refer to it again in the code.

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #1 requires good titles. I have updated it for you this time because you are a new member. --6StringJazzer
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 03-05-2020, 01:16 AM
  2. Macro to Pull Data from Multiple Workbooks to One Master Workbooks
    By eranajoy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2019, 09:24 AM
  3. VBProjects of closed workbooks shown in open workbooks VBProject window
    By ImranBhatti in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2018, 07:10 AM
  4. Macro to autoclose hidden workbooks is closing all active workbooks
    By tlchavez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2013, 06:38 PM
  5. [SOLVED] Open Multiple Workbooks, Record names, Copy paste to Active Workbook, Close the Workbooks
    By vba_madness in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 06:09 AM
  6. Replies: 0
    Last Post: 08-07-2012, 02:19 PM
  7. [SOLVED]:Opening workbooks and enabling user defined macros to run in those workbooks
    By vbarookie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-05-2012, 12:00 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1