Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Automation of worksheet protection from Access VBA - can't insertrows afterwards

I'm working on an access application that uses Excel and Outlook
automation to send spreadsheets by email,

Everything works, except that the sheets need their first 13 rows
protected (the header data), but need to permit the user to enter data
and insert rows into the detail part from the 14th row onward.

Starting with a completely unlocked, unprotected sheet, my code looks
like this:

'mark the cells locked:
objActiveWkb.Worksheets(1).Range("A1:Q13").Locked = True
objActiveWkb.Worksheets(1).Range("A1:Q13").Formula Hidden = False
'protect the sheet
'objActiveWkb.Worksheets(1).Protect ("MyPasswordHere"), DrawingObjects
= False, Scenarios = False, AllowInsertingRows = True,
AllowDeletingRows = True

I end up with a spreadsheet in which I can enter data into the detail
section (but not the first 13 rows, as desired), but I can's insert a
row anywhere in the sheet, even in the supposedly unprotected detail
section after row 14.

If I apply the protection manually, checking the Allow Deleting Rows
checkbox on the way, it works exactly as expected (but obviously I
can't expect the user to do this for the 200 spreadsheets the
application will send out each month).

What am I doing wrong?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Automation of worksheet protection from Access VBA - can't insertrows afterwards

On Jul 2, 4:18*pm, Mangetout wrote:
I'm working on an access application that uses Excel and Outlook
automation to send spreadsheets by email,

Everything works, except that the sheets need their first 13 rows
protected (the header data), but need to permit the user to enter data
and insert rows into the detail part from the 14th row onward.

Starting with a completely unlocked, unprotected sheet, my code looks
like this:

'mark the cells locked:
objActiveWkb.Worksheets(1).Range("A1:Q13").Locked = True
objActiveWkb.Worksheets(1).Range("A1:Q13").Formula Hidden = False
'protect the sheet
'objActiveWkb.Worksheets(1).Protect ("MyPasswordHere"), DrawingObjects
= False, Scenarios = False, AllowInsertingRows = True,
AllowDeletingRows = True

I end up with a spreadsheet in which I can enter data into the detail
section (but not the first 13 rows, as desired), but I can's insert a
row anywhere in the sheet, even in the supposedly unprotected detail
section after row 14.

If I apply the protection manually, checking the Allow Deleting Rows
checkbox on the way, it works exactly as expected (but obviously I
can't expect the user to do this for the 200 spreadsheets the
application will send out each month).

What am I doing wrong?


Worked it out myself in the end - it needs to be either:
objActiveWkb.Worksheets(1).Protect Password :="MyPasswordHere",
DrawingObjects :=False, Scenarios := False, AllowInsertingRows := True

Or:
objActiveWkb.Worksheets(1).Protect "MyPaswordHere", ,
True, , , , , , , True, , , True
Reply
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
automation excel to access goaljohnbill Excel Programming 1 May 21st 09 05:25 AM
Visible automated Excel: automation crashes if user selects cells, protection? Christian Friedrich Excel Programming 1 November 3rd 06 04:26 AM
Automation between Access and Excel J. Toews Excel Programming 4 October 12th 04 02:55 PM
Access Automation to Excel Bob Barnes[_3_] Excel Programming 0 January 15th 04 01:47 AM
Automation from .pdb to excel and then to access Kenny chan Excel Programming 1 December 13th 03 01:28 AM


All times are GMT +1. The time now is 04:48 PM.

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"