Excel backcolor cell from Access

Eliot

New member
Local time
Yesterday, 20:50
Joined
Dec 18, 2007
Messages
8
Hello all...

How can I change the backcolor of an excel cell from access??

I've got this variables:

Dim sheet As Object
Dim con As Connection
Dim appexcel As Object 'Excel.Application

and then:

Set appexcel = CreateObject("Excel.application")
Set conn = Application.CurrentProject.Connection
appexcel.Visible = True
appexcel.workbooks.Add
Set sheet = appexcel.sheets.Add


I can't find the way to change it anywhere!


Thank you!
 
Found this bit of code for you from http://www.pcreview.co.uk/forums/thread-1139379.php

Better to call from Access a macro in Excel to change the cell colour.

Public Sub RunExcelMacroOrSub()

'declare variables
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook

'excel application stuff
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open("c:\temp\yourfilename.xls")

'run the macro
xlApp.Run "YourMacroName"

'save file
xlBook.Save

'done
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing

End Sub
 
Hello all...

How can I change the backcolor of an excel cell from access??

I've got this variables:

Dim sheet As Object
Dim con As Connection
Dim appexcel As Object 'Excel.Application

and then:

Set appexcel = CreateObject("Excel.application")
Set conn = Application.CurrentProject.Connection
appexcel.Visible = True
appexcel.workbooks.Add
Set sheet = appexcel.sheets.Add


I can't find the way to change it anywhere!


Thank you!

off the top of my head, stick

sheet.cells.interior.colorindex=3

at the end

3 is red btw
 

Users who are viewing this thread

Back
Top Bottom