VBA Sheets.Add disabled

W

Willem

Hi,

We recently upgraded from Office 2003 to Office 2007. In some macro's errors
start occurring, e.g. the Excel macro that adds an extra sheet to a workbook,
and always worked flawless, now stops running.
Also i cannot add a worksheet manually; I can see the tab but it is disabled.
The workbook consists of several (protected) worksheets.
The macro is very simple:
Sub MakeSheet()
' Application.ScreenUpdating = False
Sheets.Add
ActiveSheet.Name = "exporteren data"
End Sub

What can be the problem?
 
J

Jacob Skaria

Try specifying the Workbook name

Workbooks("Book1").Sheets.Add
Workbooks("Book1").ActiveSheet.Name = "exporteren data"

If this post helps click Yes
 
W

Willem

Thanks for your prompt reaction, Jacob.
It won't work, because the file I.m talking about is a template (xltm) and
the users name it themselves.
I have another workbook using the same macro's, and this does not give this
problem. In the other wb i can add sheets, and in thois one it is disavbled
but i don't see how.
 
M

muddan madhu

May be the workbook is protected.

Go to Revew tab | protect workbook | any tick is there for protect
structure and windows | then its protected.

If its not protected then, check the sheet named "exporteren data" is
already exist.

Sub makesheet()
Sheets.add.name = "exporteren data"
end sub
 
W

Willem

yes, thanks. I feel so silly.......
the box for style protectiuon was ticked.
it works like it always did......

thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

For Each WS .... 2
Windows XP Help in VBA 0
split worksheet after empty row into separate workbooks 3
Excel VBA help: Text file formatting 19
Creating a Hyperlink within a marco 1
Excel VBA bug? 1
Lost in code 4
Protecting whole workbook 5

Top