P
Phil Galey
I have the following code in VB6 and am trying to copy the body text from
one document to another document. The problem I'm having is that not only
the body text is copied, but the header and footer information are also
copied. In my situation, the target document will have it's own header and
footer that are different than the original document. Thus only the body
text (with formatting) must be copied.
--------------------------------------------------------------------
Dim WApp As New Word.Application
Dim WDoc1 As Word.Document
Dim WDoc2 As Word.Document
Set WDoc1 = WApp.Documents.Open("<Path to document>")
WDoc1.StoryRanges(wdMainTextStory).Copy
Set WDoc2 = WApp.Documents.Add
WDoc2.StoryRanges(wdMainTextStory).Paste
WApp.Visible = True
Stop
WApp.Documents.Close False
WApp.Quit
one document to another document. The problem I'm having is that not only
the body text is copied, but the header and footer information are also
copied. In my situation, the target document will have it's own header and
footer that are different than the original document. Thus only the body
text (with formatting) must be copied.
--------------------------------------------------------------------
Dim WApp As New Word.Application
Dim WDoc1 As Word.Document
Dim WDoc2 As Word.Document
Set WDoc1 = WApp.Documents.Open("<Path to document>")
WDoc1.StoryRanges(wdMainTextStory).Copy
Set WDoc2 = WApp.Documents.Add
WDoc2.StoryRanges(wdMainTextStory).Paste
WApp.Visible = True
Stop
WApp.Documents.Close False
WApp.Quit