|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VBA to write into a Word doc from Outlook, then have Word VBA read what was written?
Hi All
I have a macro that I run in Outlook. At the end of that macro there is this code: Code:
job = ImputBox("Enter Job Number") Dim word As Object Set word = CreateObject("Word.Application") Template = "C:\Users\tbaker\Documents\Template.docm" With word .Visible = True .Application.Activate .Documents.Open (Template) End With I don't have any idea how to write this, but something like this mock code: Code:
With word .Visible = True .Application.Activate .Documents.Open (Template) .Write.Header = job 'made up code haha I have no idea what the code would actually be but you get the idea End with Code:
Sub readjob() Dim job As String job = Header.Value 'Completely made up code but you get the idea, its passing the variable from Outlook into Word via writing it in the word document and then VBA reading it again into a variable in Word Thanks in advance. With a little googling I found this: HeadersFooters Object (Word) using the second vba example could I use something like the below in my Outlook code: Code:
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = job Code:
job = ImputBox("Enter Job Number") Dim word As Object Set word = CreateObject("Word.Application") Template = "C:\Users\tbaker\Documents\Template.docm" With word .Visible = True .Application.Activate .Documents.Open (Template) End With Cheers |
#2
|
||||
|
||||
Hi stildawn,
Basically: Code:
With word .Visible = True .Application.Activate .Documents.Open (Template) .ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InsertBefore job End With
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Opening files with MS Word using URL with IIS 6 for read AND write. | wyattbiker | Word | 0 | 03-21-2013 07:32 AM |
Blogs Written With Word Not Posting to Wordpress | hpfan1972 | Word | 0 | 02-05-2013 04:48 PM |
Read text Report file with VBA and write parsed fields to Excel workbook | tpcervelo | Excel Programming | 1 | 01-05-2012 10:14 PM |
How to write a table of contents in word | ugurkocak1980 | Word | 4 | 05-31-2010 06:10 AM |
How to write in Word from Select query | lakhan.p | Word | 0 | 03-27-2009 07:25 AM |