Macro not working in 2003

HardAtWork

Board Regular
Joined
Sep 17, 2010
Messages
52
I have been working on a large code that changes the color in the interior of the cells, font and shapes within a file.

I will include only a portion of the code (due to the length), but my problem is that it works fine on Excel 2007 and 2010 but not in 2003. The file itself works, but not when I try to make the code changes via a push button.

Background. I started and completed the coding using XP with Excel 2007 (Not Sure if that would matter or not).

I get an error code with the code I will provide stating that it can't set the interior code. I put ** in the code were its highlights in VBA.

The file works fine on all versions without my new codes, and works fine in 2007 and 2010 with the new code.

Can ya'll assist me in finding out maybe why this code will not work in 2003?

If you would like to see the entire coding let me know and I can add it.

Here the portion of the coding I have done

Private Sub Night_Mode_Click()
If Application.Version = "11.0" Or_
Application.Version = "12.0" Or _
Application.Version = "14.0" Then
ActiveWorkbook.Unprotect "Password"
Application.ScreenUpdating = False
Worksheets("Not Compatible").Visible = True
Worksheets("Not Compatible").Select
Worksheets("Not Compatible").Unprotect "Password"
Worksheets("Not Compatible").Range("A1:T70").Interior.ColorIndex = 56 **
Worksheets("Not Compatible").Range("A1:T70").Font.ColorIndex = 4
Worksheets("Not Compatible").Shapes("Text Box 1").Select
With Selection.Font
.ColorIndex = 4
End With
Worksheets("Not Compatible").Shapes("TextBox 4").Select 'no space
With Selection.Font
.ColorIndex = 4
End With
Worksheets("Not Compatible").Shapes("TextBox 6").Select 'no space
With Selection.Font
.ColorIndex = 4
End With
Worksheets("Not Compatible").Unprotect "Passoword"
Worksheets("Not Compatible").Visible = False 'I want this page to hide, but the changes to be made
Worksheets("Not Compatible").Select
ActiveWorkbook.Protect "Password"
Application.ScreenUpdating = True
End Sub

Basically, this code gets repeated numerous times for the different tabs.

Thank you ahead of time for any assistance in this matter. This issue is the only thing that is holding me up from releasing this file for use.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
HardAtWork,
Excel 2003 will not accept .ColorIndex code which came out in 2007. Try instead:

Code:
With Selection.Font
    .Color = RGB (0, 0, 0)
End With

You will want to use the RGB equivalent of whatever ColorIndex = 4 is in the 2007 version in place of the (0, 0, 0).

Good Luck with your code.

Charles
 
Upvote 0
I've made the changes is I still can not get it to work.

Here's the new code

Private Sub Night_Mode_Click()
If Application.Version = "11.0" Or _
Application.Version = "12.0" Or _
Application.Version = "14.0" Then
ActiveWorkbook.Unprotect "Password"
Application.ScreenUpdating = False
Worksheets("Not Compatible").Visible = True
Worksheets("Not Compatible").Select
Worksheets("Not Compatible").Unprotect "Password"
Worksheets("Not Compatible").Range("A1:T70").Interior.Color = RGB(50, 50, 50)
Worksheets("Not Compatible").Range("A1:T70").Font.Color = RGB(50, 205, 50)
Worksheets("Not Compatible").Shapes("Text Box 1").Select
With Selection.Font
.Color = RGB(50, 205, 50)
End With
Worksheets("Not Compatible").Shapes("TextBox 4").Select
With Selection.Font
.Color = RGB(50, 205, 50)
End With
Worksheets("Not Compatible").Shapes("TextBox 6").Select
With Selection.Font
.Color = RGB(50, 205, 50)
End With
Worksheets("Not Compatible").Unprotect "Password"
Worksheets("Not Compatible").Visible = True
'Worksheets("Front Page").Unprotect "Password"
Worksheets("Front Page").Select
Worksheets("Front Page").Shapes("Picture 8952").Visible = False
Worksheets("Front Page").Range("FP_ScrollArea").Interior.Color = RGB(50, 50, 50)
Worksheets("Front Page").Range("FP_ScrollArea").Font.Color = RGB(50, 205, 50)
Worksheets("Front Page").Range("A62").Font.Color = RGB(50, 50, 50)
Worksheets("Front Page").Range("A99").Font.Color = RGB(50, 50, 50)
Worksheets("Front Page").Range("B3:GX120").Font.Color = RGB(50, 205, 50)
Worksheets("Front Page").Shapes("Group 311").Select
With Selection.Border
.Color = RGB(50, 205, 50)
End With

Worksheets("Front Page").Select
ActiveWorkbook.Protect "Password"
Application.ScreenUpdating = True
End Sub


It hangs up on at the same point were the last one did...also the color come out different from 2007 and 2003. I have not been able to test the code on 2010, but hopefully it works.

Do ya'll any suggestions on another place to look at in the coding?
 
Upvote 0
I've looked further into the file and found that three page interior, font, and shapes correctly (other than a weird color...that can be fixed though), but when the code gets to the fourth sheets it throws an error at the interior color change.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,261
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top