Hi - I’ve done this before but it has been a long time, and I can’t remember the details of how I did it before. What I’m trying to do is simply output data that I’ve collected from Notes databases into an Excel spreadsheet, then do some simple formatting. The output works great. Now the formatting code is giving me grief - I am getting the following errors:
-
“Variable is not declared: RANGE” (though if I put .Range with a period before it, that seems to take)
-
“Variable is not declared: SELECTION”
-
“Variable is not declared: ACTIVECELL”
Thanks for looking - any help or useful examples appreciated!
Trish
Const APPLICATION_EXCEL = "Excel.Application"
Const SHEET_1 = "Sheet1"
Const xlContinuous = 1
Const xlR1C1 = 2
Const xlCenter = -4108
Const xlBottom = -4107
Const xlGeneral = 1
Const xlContext = -5002
Set xlapp = CreateObject(APPLICATION_EXCEL)
xlapp.Visible = False
xlapp.Workbooks.Add
xlapp.ReferenceStyle = xlR1C1
xlapp.DisplayAlerts = False
Set xlsheet = xlapp.Workbooks(1).Worksheets(1)
xlsheet.Name = "DA Monthly Report"
Range("A1:K1").Select ' <----------#1
With Selection ' <-----------#2
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
ActiveCell.FormulaR1C1 = "DA Monthly Report" ' <----#3
.Range("A1:K1").Select
Selection.Font.Bold = True
.Range("A3:K3").Select