Set Cell BGColor from DTS Package?

JeffK627

Active Member
Joined
Jun 22, 2005
Messages
313
I have a DTS package that creates an Excel workbook and writes data to it. That part works fine, but I am trying to set some formatting from a VBScript and it isn't working. Here is the relevant code snippet:

Code:
Dim s

    For Each s in objXLB.Worksheets

        With s.Range("A1:IV65536").Font
            .Name = "Arial"
            .FontStyle = "Regular"
            .Size = 8
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .ColorIndex = xlAutomatic
            objLogFile.WriteLine("Font formatted.")
        End With

        With  s.Range("A1:IV1")
            .Font.FontStyle = "Bold"
            .Interior.ColorIndex = 15
            .Interior.Pattern = xlSolid
            objLogFile.WriteLine("Top row formatted.")
        End With

    Next

The font face, size, style (bold) and color are all fine, but it is not setting the background color - it apparently is ignoring the ".Interior.ColorIndex = 15" part. Can anyone help?
 
Is this late bound? If so, then xlSolid has no definition. Try your original code, but with
Code:
.Interior.Pattern = 1
Does that work?
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

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