Automation with Excel

B

BFarrell

Is there a way to assign Conditional Formatting in Excel from Access? I am
trying to use the FormatConditions method but it does not seem to apply to
the xlObject.
 
K

Klatuu

This comes from Access 2003 Help. Maybe your problem is addressing the wrong
object.

With Worksheets(1).Range("e1:e10").FormatConditions _
.Add(xlCellValue, xlGreater, "=$a$1")
With .Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 6
End With
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
 
D

David C. Holley

I would open up the VB Editor in Excel and dig through the OBJECT
REFERENCE help files. I have actually found that the help files on the
various Object Models to be somewhat complete and useful (even though it
is MS).
 
B

BFarrell

Well that is what the Excel help file is referencing when using VBA in Excel.
I am trying to modify excel files and assign conditional formatting while
running vba code in Access. I have referenced the excel object appropriately
for other formatting and functions to work.

The code I was trying works great in excel, but when running from Access I
receive an "Invalid procedure call or argument" error.
 
K

Klatuu

It doesn't matter where the code is running from as long as you get your
references correct. In this case try:
Dim xlApp as Excel.Application

With xlApp.Worksheets(1).Range("e1:e10").FormatConditions _
.Add(xlCellValue, xlGreater, "=$a$1")
With .Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 6
End With
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
 
Top