Changing Header info in a text box

S

Scott

I have a macro that gets run from Outlook. You open up a meeting
request and hit my macro button and the macro opens up a word template
and pulls info from the meeting request and puts it into a table on my
word document. I have the part working where it puts the text into the
table in the body of the template but I am having problems with
inserting text into a cell in the table in the primary header. The
last line of the macro below is where I am trying to put the text in
with. If you remove wordapp. from the begining of the line the
remainder of the line works fine if called from a macro within word.
When I run this macro from Outlook it tells me "The requested member
of the collection does not exist" When I hover my cursor over
wdHeaderFooterPrimary it shows "Empty" but it shows "1" when in word
VBA. I tried to just enter 1 in the Outlook VBA but that did not work
either.
I would appreciate any help or ideas on how to change this text from
Outlook.

Thanks
Scott

Sub MeetingToWord()
Dim myolapp As Outlook.Application
Dim myinspector As Outlook.Inspector
Dim A As String

Set myolapp = CreateObject("Outlook.Application")
Set myinspector = myolapp.ActiveInspector
'Set MyData = New DataObject 'Used to copy to the clip board
'On Error GoTo 10
A = myinspector.CurrentItem.RequiredAttendees
S = myinspector.CurrentItem.Subject
L = myinspector.CurrentItem.Location
ST = myinspector.CurrentItem.Start
E = myinspector.CurrentItem.End
B = myinspector.CurrentItem.Body
D = E - ST 'Duration of meeting

Set wordapp = CreateObject("Word.Application")
wordapp.Visible = True
If wordapp Is Nothing Then
MsgBox "Couldn't Start Word . . . ."
Else
Set oDoc = wordapp.Documents.Add("H:\Templates\Meeting
Minutes.dot")
End If
'
'Update header Info
'

wordapp.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1).Cell(2,
3).Range.Text = "Last Cell"

End sub
 
J

Jay Freedman

The named constant wdHeaderFooterPrimary is defined only in the Word
object library, so you can use it only if you set a reference to that
library (in the VBA editor, go to Tools > References and put a check
next to Microsoft Word Object Library).

However, the numeric value 1 should work, and it does work when I try
it. What happens when you try it?

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
S

Scott

I put a 1 in for "wdHeaderFooterPrimary" and it worked. I thought that
I had tried that and it gave a error earlier. It worked this time
though.
Thanks a bunch.

Scott
 

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