Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

copy & pasting text but keeping format

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Katy White - 29 Aug 2005 22:04 GMT
I need to concatenate the contents of multiple documents into a singe
document.  I used VB 6 but am using a word document object.  I have most of
this working but I am having trouble keeping the formatting of the original
document when I paste it into the new document.  Currently I am using --

         ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
         Selection.HomeKey unit:=wdStory
         
         Word.Application.Selection.WholeStory
         Word.Selection.Copy
         'close the file without changing anything
         Word.Application.Saved = True
         Word.Applicaton.Close
         
          wdDoc1.Activate 'destination file
           
           Selection.Paste
           'end old stuff
           Selection.WholeStory
           Selection.EndKey unit:=wdStory
           'insert a section break
           Selection.InsertBreak Type:=wdSectionBreakNextPage
           Selection.HeaderFooter.LinkToPrevious = False

This code works perfectly in VBA but for some reason I loose the formatting
in VB. All the information comes over correctly (it's actually all in tables
with headers and footers on each page and some portions of text are bolded)
but the font size does not come over.  I tried copying styles from the
original to the new (Normal in the original is 10 pt and Normal in the next
doc is 12 pt) but that doesn't help either.  

Suggestions?
           
jay - 31 Aug 2005 17:33 GMT
Does the text have any overrides - paragraph or character formatting on
top of the 'normal' style?
I guess you could loop through the paragraph ranges and remove
overrides or apply the style of your choice?
Or- do a s&r for the style/formatting ?
Katy White - 31 Aug 2005 21:16 GMT
Hi Jay,

The original docs are in RTF ... everything is Normal as a style (they are
SAS 9 output) but there is some formatting applied (mostly just bold to some
sections).  When I copy everything over I keep everything (including tables
and bold in the appropriate places) but the font goes from 10 pt to 12 pt.  I
tried copying the style from the old doc to the new one but that didn't seem
to work:

With ActiveDocument
       .UpdateStylesOnOpen = False
       .AttachedTemplate = "Normal"
       .XMLSchemaReferences.AutomaticValidation = True
       .XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = False
End With
Application.OrganizerCopy Source:= strSource, Destination:= strDest, _  
      Name:="Normal", Object:=wdOrganizerObjectStyles

The source doc font size for normal is 10pt and the normal.dot font size is 12

Is there something I'm not doing correctly here?

> Does the text have any overrides - paragraph or character formatting on
> top of the 'normal' style?
> I guess you could loop through the paragraph ranges and remove
> overrides or apply the style of your choice?
> Or- do a s&r for the style/formatting ?

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.