Error Using WORKBOOK.ADD() without First ArgumentID: Q84172
|
Microsoft Excel requires a worksheet name for the first argument in the
WORKBOOK.ADD() function. If you use this macro function without the first
argument, you receive a macro error when you run the macro that contains
this function.
In Microsoft Excel version 5.0, if you use this function in a Microsoft
Excel version 4.0 macro sheet without the first argument, you receive a
general protection (GP) fault.
You can use the WORKBOOK.ADD function to add one or more documents to a
workbook in Microsoft Excel version 4.0. If the worksheet argument is left
out in most functions, the active sheet is assumed. This is not the case
for the WORKBOOK.ADD function.
The WORKBOOK.ADD function requires a first argument and will halt on a
macro error if no argument is given. This also applies to the
WORKBOOK.COPY() and WORKBOOK.MOVE() functions.
Method 1: Use the WORKBOOK.MOVE function instead of the WORKBOOK.ADD
function. You can use the WORKBOOK.MOVE function without the
first argument to move the active sheet to the specified
workbook, unless the active sheet is the only sheet contained in
the workbook.
Method 2: Use the Move method of the Sheets object to move the active sheet
to another workbook. The following example moves the active
sheet to BOOK1:
ActiveSheet.Move Workbooks("Book1").Sheets(1)
Note that the sheet is inserted before Sheet1 in BOOK1.
"Function Reference," version 4.0, page 461
Additional query words: 4.0 work book gpf
Keywords :
Version : 4.00 5.00
Platform : WINDOWS
Issue type :
Last Reviewed: March 24, 1999