Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting Excel from Access

Status
Not open for further replies.

kopy

Technical User
May 30, 2002
141
US
I'm trying to export an Access report to Excel and then add some labels and formulas that do not export. My first roadblock is that Access VBA doesn't recognize the value in the formatting command:

oApp.Underline = xlUnderlineStyleNone

Access sees xlUnderlineStyleNone as an ubdefined variable. My code so far is listed below.

Any help with this issue will be greatly appreciated.
Thanks, Mike
-----------------------------------------------------------
Dim oApp As Object

DoCmd.OutputTo acReport, "qryCurrentQtrStats", "MicrosoftExcel(*.xls)", "c:\hvma\FY2002_Turnover_Dashboard\CurrentQtrStats.xls", False, ""

Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
'Open the Workbook
oApp.Workbooks.Open "C:\hvma\FY2002_Turnover_Dashboard\CurrentQtrStats.xls"
oApp.Rows("1:1").Select
oApp.Selection.Insert Shift:=1
oApp.ActiveCell.FormulaR1C1 = "FY2002 Quarter"
oApp.Range("A1").Select
oApp.Selection.Font.Bold = True
With oApp.Selection.Font
oApp.Name = "MS Sans Serif"
oApp.Size = 24
oApp.Strikethrough = False
oApp.Superscript = False
oApp.Subscript = False
oApp.OutlineFont = False
oApp.Shadow = False
oApp.Underline = xlUnderlineStyleNone
oApp.ColorIndex = 1
End With
 
this is possible, u have to set the references Excel 10.0 or something maybe u have to put it into quotes "" but I'm not sure
Hope this helps,
else u can come back
gerard
 
Remove the "oApp" references from your with block.

With oApp.Selection.Font
.Name = "MS Sans Serif"
.Size = 24
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With

HTH
Wayne
 
I removed the oApp references from the formatting block and I also deleted the option explicit declaration from the module.

My current error message is:

"Unable to set the Underline property of the Font Class"

Thanks,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top