Add a Header to Word from VBA? Help.

Joined
Sep 5, 2007
Messages
4
Reaction score
0
I'm working on an excel application that prints out a Word Documnet report from a query. I got it to work functionally, but now I would like to add a header, and I honestly can't figure out how to do it. Any help out there?



managerFID = Me.cboCriteriaChoices.Column(1)
Set oWord = CreateObject("Word.Application")
Set reportDoc = oWord.Documents.Add
Set oRange = reportDoc.Words(1)
reportDoc.PageSetup.Orientation = wdOrientLandscape
managerName = Me.cboCriteriaChoices.Value


Set SIP = CreateObject("ADODB.Connection")
SIP.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=S:\Fin and Corporate\Skills Inventory Project\SDLC_PMLC\Database\SIPDB.mdb; Persist Security Info = False"

Set rst = SIP.Execute( _
"SELECT ManagerResults.Id_Emp, ManagerResults.LastName_Emp,
ManagerResults.FirstName_Emp, ManagerResults.Name_Skills,
ManagerResults.Desc_Ctgy, ManagerResults.Level_Expertise,
ManagerResults.Comments_Emp_Skill FROM ManagerResults WHERE[ManagerResults]![Manager_Emp_Resource]='" & managerFID & "'
ORDER BY ManagerResults.LastName_Emp;")
sTemp = rst.GetString(adClipString, -1, vbTab)


sTemp = "FID" & vbTab & "Last Name" & _
vbTab & "First Name" & vbTab & "Skills" & vbTab & "Category" & vbTab & "Expertise" & vbTab & "Comments" & vbCrLf & sTemp
oRange.Text = sTemp
oRange.ConvertToTable vbTab, , , , wdTableFormatContemporary

reportDoc.PrintOut
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top