error in attempt to warn about macro security

  • Thread starter Pierre via OfficeKB.com
  • Start date
P

Pierre via OfficeKB.com

Hi,

I have the followign code .....

Private Sub Workbook_Open()
Dim Sheet As Worksheet
For Each Sheet In Worksheets
If Sheet.Name <> "waarschuwing" Then
Sheet.Visible = xlSheetHidden
End If
Next Sheet
Sheets("waarschuwing").Visible = xlSheetVeryHidden
Set Sheet = Nothing
end sub

When the code is run, i get an error message:

erro 1004
characteristic visible of class worksheet cannot be use

any ideas?
Pierre
 
G

Guest

In any workbook there must be at least 1 visible sheet. You are trying to
hide all of the sheets which will not work...
 
P

Pierre via OfficeKB.com

Hi Jim,

thanks for replying but i do not think i am closing all the sheets.
The sheet called "waarschuwing" is still visible....

any other suggestions?
Pierre

Jim said:
In any workbook there must be at least 1 visible sheet. You are trying to
hide all of the sheets which will not work...
[quoted text clipped - 18 lines]
any ideas?
Pierre
 
P

Pierre via OfficeKB.com

Hi Jim,

you were right afterall !!!
Thanks,
Pierre

P.S. i now have the right code but now i see the "warning" sheet for a few
seconds when i start the application. is there a way to not see this sheet at
all when the application starts and the macros are not disabled?
thanks,
Pierre


Jim said:
In any workbook there must be at least 1 visible sheet. You are trying to
hide all of the sheets which will not work...
[quoted text clipped - 18 lines]
any ideas?
Pierre
 
P

Pierre via OfficeKB.com

Hi Jim,

The code works fine now, however,

on startup i still see the warning screen flashing by.
Is there a way to prevent this from happening?

I tried
Application.Screenupdating = False
DoEvents

but that did not do the trick...
any ideas?
Thanks,
Pierre

Jim said:
In any workbook there must be at least 1 visible sheet. You are trying to
hide all of the sheets which will not work...
[quoted text clipped - 18 lines]
any ideas?
Pierre
 
G

Guest

In your on close hide all but the warning sheet... Whe the book is opened if
macros are disabled then no code runs and only the warning sheet is visible.
YOu will also want to use

Application.screenupdating = false
'Your code
Application.screenupdating = true 'at the end of the sub

--
HTH...

Jim Thomlinson


Pierre via OfficeKB.com said:
Hi Jim,

you were right afterall !!!
Thanks,
Pierre

P.S. i now have the right code but now i see the "warning" sheet for a few
seconds when i start the application. is there a way to not see this sheet at
all when the application starts and the macros are not disabled?
thanks,
Pierre


Jim said:
In any workbook there must be at least 1 visible sheet. You are trying to
hide all of the sheets which will not work...
[quoted text clipped - 18 lines]
any ideas?
Pierre
 
T

Tom Ogilvy

The code doesn't execute until the workbook is opened.

You could try hiding the workbook and saving it (Like personal.xls). In
your code, you then set up the workbook the way you want to see it and then
make it visible.

In the before close event, you would need to hide it again and save it.

--
Regards,
Tom Ogilvy


Pierre via OfficeKB.com said:
Hi Jim,

The code works fine now, however,

on startup i still see the warning screen flashing by.
Is there a way to prevent this from happening?

I tried
Application.Screenupdating = False
DoEvents

but that did not do the trick...
any ideas?
Thanks,
Pierre

Jim said:
In any workbook there must be at least 1 visible sheet. You are trying to
hide all of the sheets which will not work...
[quoted text clipped - 18 lines]
any ideas?
Pierre
 

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

Top