PC Review


Reply
Thread Tools Rate Thread

Add a Header to Word from VBA? Help.

 
 
New Member
Join Date: Sep 2007
Posts: 4
 
      11th Sep 2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header missing when opening a Word 2003 doc in Word 2007 Jen Microsoft Word New Users 15 24th Mar 2009 04:11 PM
generating word document with header and footerwithout using word object. srk Microsoft ASP .NET 0 25th Apr 2007 07:34 AM
generating word document with header and footerwithout using word object. srk Microsoft ASP .NET 0 24th Apr 2007 02:59 PM
Re: Header and Footer missing: Word 2003 doc edited in Word 2000 John McGhie [MVP - Word and Word Macintosh] Microsoft Word Document Management 2 3rd Feb 2007 12:28 PM
Header formatting (Word 2000) - how to hide individual header =?Utf-8?B?cmdm?= Microsoft Word Document Management 2 21st Apr 2004 01:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:45 PM.