Formatting Excel using Access VBA

G

Guest

..Cells(27, 1).Value = "Best Regards,"
.Cells(28, 1).Value = "MMO Office"

With .Range(.Cells(29, 1), .Cells(29, 4))
.Font.Italic = True
.MergeCells = True
With .Borders(9) ' xlEdgeBottom: 9
.LineStyle = 1 ' xlContinuous: 1
.Weight = 2 ' xlThin: 2
.ColorIndex = -4105 ' xlAutomatic: -4105
End With

End With

This is the last of the code.
End With
Cells.Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
objExcel.Visible = True

Set objExcel = Nothing
Set wkb = Nothing
Set wks = Nothing

Excel macro's are not always helpful when using in Access.
Above is a portion of the code I am using in Access to format the data in
Excel for row 29 which works ..
The very last thing I want to do is hide the gridlines by making the
worksheet white.
I ran a Macro and got this,but I placed this code right after the last ENd
With. I kept receiving OBject and Method errors.

Tried rearranging the code and still got same error. I even tried
Activeworksheet.cells,same error.

Could I be placing the code in the wrong place?
 
G

Guest

Cyndy,
The problem is that your Cells reference is not fully qualified. This is
really a Range operation:

With .Range(???).Interior
.ColorIndex = 2
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top