Hi all,
I have Export data from access to Excel worksheet.
I am trying to change font weight form normal to Bold form each Schedule heading and Schedule table colmn headings on the fly.
I have tried by using:
with objWs.Row(PreColheading, PreColHeading+3)
.Font.Bold = True
.Cell(..)
end with
However, I got error msg:"Application or Object Not defined"
the following is my function witch produces and schedule heading :
Function FillScheduleHeading(objWS As Excel.Worksheet, preHeading As Integer, ExamPlace As String, Session As String) _
As Integer
Dim HeadingData As Recordset
Dim HeadingSql As String
Dim NextIRow As Integer
HeadingSql = "SELECT * FROM ExamLocation " _
& "WHERE ((ExamLocation.Location) Like '*" & ExamPlace & "*')"
Set HeadingData = CurrentDb.OpenRecordset(HeadingSql)
' MsgBox "debug" & CStr(HeadingData!Address)
With objWS
'MsgBox "Debug Font"
' With Worksheets(objWS).Rows(preHeading, preHeaging + 3)
'.Font.Bold = True
'.FontSize = 12
'Set up Exam Schedule/subSchedule heading
.Cells(preHeading, 1).Value = "SessionYear"
'.Cells(preHeading, 1).Font.Bold
.Cells(preHeading, 2).Value = Session
' .Cells(preHeading, 2).Font.Bold
.Cells(preHeading + 1, 1).Value = "Location"
'.Cells(preHeading + 1, 1).Font.Bold
.Cells(preHeading + 1, 2).Value = ExamPlace
'.Cells(preHeading + 1, 2).Font.Bold
.Cells(preHeading + 2, 1).Value = "Address"
' .Cells(preHeading + 2, 1).Font.Bold
.Cells(preHeading + 2, 2).Value = CStr(HeadingData!Address) & " " & CStr(HeadingData!Region) _
& " " & CStr(HeadingData!Country)
' .Cells(preHeading + 2, 2).Font.Bold
.Cells(preHeading + 3, 1).Value = "Contact Officer"
'.Cells(preHeading + 3, 1).Font.Bold
.Cells(preHeading + 3, 2).Value = CStr(HeadingData!ContactOffice)
'.Cells(preHeading + 3, 2).Font.Bold
'End With
End With
NextIRow = 4
FillScheduleHeading = NextIRow
HeadingData.close
Set HeadingData = Nothing
End Function
I have post same question on Automation: Access to Excel for several days.
Could anybody help me?
Any help is appreciated
Wei Zhang
I have Export data from access to Excel worksheet.
I am trying to change font weight form normal to Bold form each Schedule heading and Schedule table colmn headings on the fly.
I have tried by using:
with objWs.Row(PreColheading, PreColHeading+3)
.Font.Bold = True
.Cell(..)
end with
However, I got error msg:"Application or Object Not defined"
the following is my function witch produces and schedule heading :
Function FillScheduleHeading(objWS As Excel.Worksheet, preHeading As Integer, ExamPlace As String, Session As String) _
As Integer
Dim HeadingData As Recordset
Dim HeadingSql As String
Dim NextIRow As Integer
HeadingSql = "SELECT * FROM ExamLocation " _
& "WHERE ((ExamLocation.Location) Like '*" & ExamPlace & "*')"
Set HeadingData = CurrentDb.OpenRecordset(HeadingSql)
' MsgBox "debug" & CStr(HeadingData!Address)
With objWS
'MsgBox "Debug Font"
' With Worksheets(objWS).Rows(preHeading, preHeaging + 3)
'.Font.Bold = True
'.FontSize = 12
'Set up Exam Schedule/subSchedule heading
.Cells(preHeading, 1).Value = "SessionYear"
'.Cells(preHeading, 1).Font.Bold
.Cells(preHeading, 2).Value = Session
' .Cells(preHeading, 2).Font.Bold
.Cells(preHeading + 1, 1).Value = "Location"
'.Cells(preHeading + 1, 1).Font.Bold
.Cells(preHeading + 1, 2).Value = ExamPlace
'.Cells(preHeading + 1, 2).Font.Bold
.Cells(preHeading + 2, 1).Value = "Address"
' .Cells(preHeading + 2, 1).Font.Bold
.Cells(preHeading + 2, 2).Value = CStr(HeadingData!Address) & " " & CStr(HeadingData!Region) _
& " " & CStr(HeadingData!Country)
' .Cells(preHeading + 2, 2).Font.Bold
.Cells(preHeading + 3, 1).Value = "Contact Officer"
'.Cells(preHeading + 3, 1).Font.Bold
.Cells(preHeading + 3, 2).Value = CStr(HeadingData!ContactOffice)
'.Cells(preHeading + 3, 2).Font.Bold
'End With
End With
NextIRow = 4
FillScheduleHeading = NextIRow
HeadingData.close
Set HeadingData = Nothing
End Function
I have post same question on Automation: Access to Excel for several days.
Could anybody help me?
Any help is appreciated
Wei Zhang
Last edited: