473,670 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel protect sheet macro problem

I have an Access 97 database in which I am running an Excel macro through
automation. The macro in Excel is as follows:

Worksheets("She et1").Protect Password:="**** ", DrawingObjects: =True,
Contents:=True, Scenarios:=True

When I call this macro from the database all works fine except when I
recorded the macro I deselected the "Select locked cells" option under the
"Allow all users of this worksheet to:" section but yet when I access the
worksheet I can still select a locked cell. I get a message when I do so
letting me know it is locked but I don't want the user to be able to select
locked cells.

The macro is run in a new copy of the spreadsheet every time it runs due to
a filecopy command in the database. Could this be causing the problem?

I tried using the following code in the macro:
Worksheets("She et1").EnableSel ection = xlUnlockedCells but once the
spreadsheet is closed this code has no affect. Adding this code to the on
open event of the spreadsheet is not an option due to the users that will be
receiving this spreadsheet are told to not enable macros on all
spreadsheets. Company policy!

Does anyone have a suggestion? Is there a parameter that I can add to my
protect macro?

Any help would be greatly appreciated.
Nov 13 '05 #1
1 4555
You need to call Worksheet.Enabl eSelection before you protect the sheet.

IOW you have to

On Thu, 10 Feb 2005 23:40:44 -0500, "Giganews" <he******@yahoo .com>
wrote:
I have an Access 97 database in which I am running an Excel macro through
automation. The macro in Excel is as follows:

Worksheets("Sh eet1").Protect Password:="**** ", DrawingObjects: =True,
Contents:=True , Scenarios:=True

When I call this macro from the database all works fine except when I
recorded the macro I deselected the "Select locked cells" option under the
"Allow all users of this worksheet to:" section but yet when I access the
worksheet I can still select a locked cell. I get a message when I do so
letting me know it is locked but I don't want the user to be able to select
locked cells.

The macro is run in a new copy of the spreadsheet every time it runs due to
a filecopy command in the database. Could this be causing the problem?

I tried using the following code in the macro:
Worksheets("Sh eet1").EnableSe lection = xlUnlockedCells but once the
spreadsheet is closed this code has no affect. Adding this code to the on
open event of the spreadsheet is not an option due to the users that will be
receiving this spreadsheet are told to not enable macros on all
spreadsheets . Company policy!

Does anyone have a suggestion? Is there a parameter that I can add to my
protect macro?

Any help would be greatly appreciated.


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
17404
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed a database for her which is intended to make things a lot easier; however, I don't have a lot of experience with Access and I find that designing the reports in Access is tedious. I want to be able to print the reports (which are simply based on...
8
6547
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a macro. (I'll get to using VB later on). What I would like to do is import a single workbook w/three seperate worksheets into three seperate access tables AND truncate the time stamp that is used in the excell sheet via a macro.
14
5784
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the SQL DATABASE, probably by the click of a button. Is this possible? & what is the BEST APPROACH for doing this? & also if any links are there do tell those to me too coz I have no idea how to go about doing it.
4
10094
by: Rich Wallace | last post by:
Is there a way to open an Excel file and either respond to or supress the Macro warning window via VB.NET? Dim oExcel As Excel.Workbook Dim sFilePath As String = "C:\DailyReport.xls" oExcel = GetObject(sFilePath) --> Throws Macro warning window oExcel.Unprotect("password")
4
15007
by: Jiro Hidaka | last post by:
Hello, I would like to know of a fast way to export data source data into an Excel sheet. I found a way from C# Corner(Query Tool to Excel using C# and .NET) which is a neat little way of exporting dataset data to an excel using the Excel COM object. This works fine but the problem is its pretty darn slow when exporting large
4
14547
by: e.h.doxtator | last post by:
All I'm a Python newbie, and I'm just getting to the wonders of COM programming. I am trying to programmatically do the following: 1. Activate Excel 2. Add a Workbook 3. Add a Worksheet 4. Populate the new Worksheet 5. Repeat steps 3,4 while there is data.
4
16095
by: shara | last post by:
Hello, I have a php script that outputs an excel sheet.The user has to download macro every time he wants to run the macro on the excel sheet. Is there anything in php where the code downloads macro also along with the excel sheet or something like a button in excel sheet itself, clicking on which the macro runs on the excel sheet. Any help is well appreciated. Thanks&Regards, Shara.
0
3201
by: Taxman | last post by:
Windows XP, MS Office Excel 2003 If the tasks, I’m trying accomplish have been addressed previously (separately or in combination). Please, provide the links or keyword search to find them. I’ve been searching for code for each part of the task separately and trying to piece together multiple macros, that do something similar, to what I’m trying to accomplish in my over all task, but I’m not having a lot of luck. So, here’s the entire task,...
2
1195
by: grego9 | last post by:
Is it possible to create a macro that prompts the user to enter a password to access a specific sheet in Excel 2000? I can protect a sheet - but I cannot get a password prompt if the user tries to access the sheet. thanks
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8388
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8663
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7423
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5687
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.