+ Reply to Thread
Results 1 to 6 of 6

Run-Time Error when adding chart to protected sheet

  1. #1
    Registered User
    Join Date
    06-25-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    34

    Question Run-Time Error when adding chart to protected sheet

    I have a database macro which creates charts. I just finished the program, and after protecting the sheets. I can no longer add charts. I get an error on the line where you add the chart:

    Please Login or Register  to view this content.
    Error:

    Run-Time Error '1004': Application defined or object defined error

    I protected all the sheets manually (same password) and added the following protection code (all under one same password):

    Please Login or Register  to view this content.
    Any ideas on what I am missing?

    Thanks.
    Last edited by nbuk; 07-22-2010 at 10:59 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,380

    Re: Run-Time Error when adding chart to protected sheet

    You need to unprotect the sheet, add the chart and re-protect the sheet.

    The fact that it's protected stops you changing it, hence the error.

    Regards

  3. #3
    Registered User
    Join Date
    06-25-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Run-Time Error when adding chart to protected sheet

    That's why when the workbook is open, I used the "UserInterFaceOnly:=True" which to my understating should solve that issue...

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Run-Time Error when adding chart to protected sheet

    The Userinterfaceonly:=True option is unreliable with objects, in my experience, so I would suggest you unprotect, add the chart then reprotect.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    06-25-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Run-Time Error when adding chart to protected sheet

    The reason I am trying to use userinterfaceonly is because I have over 20 sheets, and protecting and unprotecting them all individually would take a while. Are there any other options out there?

    EDIT: unprotected and protected each sheet in vba separately. works fine.
    Last edited by nbuk; 07-22-2010 at 10:59 AM.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Run-Time Error when adding chart to protected sheet

    Well, your code ought to be:
    Please Login or Register  to view this content.
    but again, I don't know how reliable it would be.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1