+ Reply to Thread
Results 1 to 4 of 4

Color Index Error-ThisWorkBook

  1. #1
    Registered User
    Join Date
    03-05-2017
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    29

    Color Index Error-ThisWorkBook

    Hi Team,

    I am using the below code.

    Private Sub Workbook_Open()

    Sheets("AD").Select
    Sheets("AD").Cells.Interior.Color = xlNone
    Call sbProtectSheet
    End Sub

    Sub sbProtectSheet()
    ActiveSheet.Protect "xxx", True, True
    End Sub

    Sub sbUnProtectSheet()
    ActiveSheet.Unprotect "xxx"
    End Sub


    Color1.jpg

    When files open I am getting the "Run-Time Error 1004.Application Defined or object define error". Please advise me.

    I am planning when the file open then it will protect the Sheets("AD") and remove the entire fill colour from the sheet.

    Please advise me.

    Regards,Waqar
    Attached Images Attached Images

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Color Index Error-ThisWorkBook

    Try this instead.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    03-05-2017
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    29

    Re: Color Index Error-ThisWorkBook

    Thanks a lot.

    It works now without any error.

    Thanks for your support.

    Regards/Waqar

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Color Index Error-ThisWorkBook

    You're welcome and thanks for rep+.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Removing Code from ThisWorkbook and error msg
    By karacooks in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-13-2016, 04:21 PM
  2. [SOLVED] Compile error in hidden module: ThisWorkbook.
    By matrixpom in forum Excel General
    Replies: 1
    Last Post: 07-08-2015, 11:33 PM
  3. ThisWorkBook.Path Generates an Error
    By Winon in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-22-2011, 10:41 AM
  4. Error on ThisWorkbook.Close method
    By Matt W in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-24-2011, 08:35 PM
  5. ThisWorkbook.PublishObjects.Add runtime error 1004
    By itarnak in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-26-2005, 06:26 AM
  6. Compile error in hidden module: ThisWorkbook
    By Lloyd in forum Excel General
    Replies: 1
    Last Post: 05-27-2005, 07:05 PM
  7. RE: Compile error in hidden module: ThisWorkbook
    By Peo Sjoblom in forum Excel General
    Replies: 0
    Last Post: 05-27-2005, 05:05 PM

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