LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Run a code on a workbook?

Hello!

I am trying to create an Excel file which is macro-free (many of the
users click No on the "macros may cause viruses"warning.)


But there are so many great bell-and-whistles available that are only
doable via VBA.


Anyway, I found somebody's great code on the Internet:


Sub Test()
Dim ws As Worksheet
Dim result As String


result = ""


For Each ws In Worksheets
result = result & ws.Name & " is " & IIf(ws.ProtectContents,
"protected", "unprotected") & vbCr
Next ws


MsgBox result
End Sub


It loops through all the sheets in your workbook and gives you a
mini-
printout of which sheets are protected and which aren't.


My workbook has 45 sheets and to edit them, I have to unprotect-edit-
then reprotect, so this is a good macro to make sure that I
reprotected everything before I send it out to my users.


It is possible to put the code outside of the workbook somewhere and
then run it on the workbook? I don't want to open the workbook and
add
a module (because then you get the macro warning), so I would like to
put the macro somewhere (a second workbook?) and then run it on the
closed workbook to make sure that all the sheets are protected. If
the
code also had a line about whether or not the workbook itself was
protected, that would be the bomb.


Any help appreciated!

VR/

Lost


 
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
Code to change code in a sheet and workbook module Otto Moehrbach Excel Programming 11 November 11th 07 07:20 PM
copy and paste using code from workbook to workbook bigdaddy3 Excel Discussion (Misc queries) 2 September 14th 05 11:06 AM
run code on opening workbook and apply code to certain sheets Jane Excel Programming 7 August 8th 05 09:15 AM
Code in one workbook to call code in another XL file [email protected] Excel Programming 2 August 1st 05 03:37 PM
Reference code in another workbook from a calling workbook Datasort Excel Programming 1 January 4th 05 01:13 AM


All times are GMT +1. The time now is 01:20 AM.

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

About Us

"It's about Microsoft Excel"