I'd suggest putting the "".Select" on a new line: I think you're actually 
destroying the With...End
With construct

HTH


John in Brisbane



-----Original Message-----
From: PDML [mailto:[email protected]] On Behalf Of Collin B
Sent: Thursday, 8 October 2015 23:27
To: [email protected]
Subject: ot: vba guru needed

As previously observed I'm not much of a VBA guru.
Writing Excel macro.  
Need to create Word document and write header with auto page numbers.
(Office 365).
Research has proven unfruitful.
This is what I've come up with.
On the    .TypeText Text:="Page "    line I get "object required" for some
reason.  Can't figure out why.

    Set objHeader =
wDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range
        
    With objHeader.Select
        .TypeText Text:="Page "
        .Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="PAGE ",
PreserveFormatting:=True
        .TypeText Text:=" of "
        .Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="NUMPAGES 
",
PreserveFormatting:=True
        .TypeText = oText
    End With


--
PDML Pentax-Discuss Mail List
[email protected]
http://pdml.net/mailman/listinfo/pdml_pdml.net
to UNSUBSCRIBE from the PDML, please visit the link directly above and follow 
the directions.


-- 
PDML Pentax-Discuss Mail List
[email protected]
http://pdml.net/mailman/listinfo/pdml_pdml.net
to UNSUBSCRIBE from the PDML, please visit the link directly above and follow 
the directions.

Reply via email to