Worksheets.Add method
Try this variation:
Set oSht = oDoc.Worksheets.Add
Objects need to be assigned to variables with Set.
In article ,
"Bruce Lindsay" wrote:
I have tried to add a worksheet with the following code.
dim oDoc as Workbook
dim oSht as Worksheet
Set oDoc = Application.ThisWorkbook
oSht = oDoc.Worksheets.Add
It gives an error #1004. I have tried it in many variations but all fail.
Some even create the sheet but still error out. Any help would be
appreciated.
|