LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Runtime error with sheets.add

Unqualified references?

Dim NameOfWorkbook as string
NameOfWorkbook = ThisWorkbook.Name

With ThisWorkbook
.WorkSheets.Add after:=.WorkSheets(.WorkSheets.Count)
End With

--
HTH

Bob Phillips

"ittac" .(I_Hate_Spam) wrote in message
...
Hi NG,

probably this question has been asked before, but I couldn't find an

answer.
Problem:
I have a Excel 2003 - VBA-module. In this module I need to create a new

sheet.
the code looks like this:

Dim NameOfWorkbook as string
NameOfWorkbook = ThisWorkbook.Name

Workbooks(NameOfWorkbook).Sheets.Add
after:=Workbooks(NameOfWorkbook).Sheets(Sheets.Cou nt)

if I try to add a sheet manually, everything works fine.

But I get a Runtime error "-2147319784 (80028018)
Method Add of object sheets failed"
when I try to add thew sheet using the code.

Any help would be greatly appreciated.

Regards
Bodo



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Runtime error '1004' General ODBC error star_lucas New Users to Excel 0 August 29th 05 04:09 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
naming tab macro error runtime error 1004 D Excel Programming 3 February 28th 05 01:32 AM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 11:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"