J
John
I've taken over a VB.NET application that opens RTF documents, performs
some editing, and performs a copy/paste of those RTF documents into a
Word Document. If I manually perform the same actions, formatting from
the source RTF documents is maintained when pasted into the destination
Word document. I see the proper margins.
However, when performing the same actions in code, the formatting from
the RTF documents is NOT maintained when pasted. I think the normal.dot
settings are used.
Following is a sample of the VB.NET code being used:
'Retrieve source RTF document contents.
Source.Activate()
Source.Selection.HomeKey(Word.WdUnits.wdStory)
Source.Selection.WholeStory()
Source.Selection.Copy()
'Paste into destination document.
Destination.Activate()
Destination.Selection.PasteAndFormat(Word.WdRecoveryType.wdFormatOriginalFormatting)
As you can see, I am using the "wdFormatOriginalFormatting" flag but it
doesn't seem to matter.
Curiously, if I set a breakpoint on the
Destination.Selection.PasteAndFormat() line, select the destination
document and perform a CTRL-V, I see the same incorrect formatting
issue.
If I then open a new instance of Word and perform a CTRL-V to copy the
same data from the Clipboard to the newly created document, the
formatting is correct.
Can someone out there please tell me what the heck I'm doing wrong?
-John
some editing, and performs a copy/paste of those RTF documents into a
Word Document. If I manually perform the same actions, formatting from
the source RTF documents is maintained when pasted into the destination
Word document. I see the proper margins.
However, when performing the same actions in code, the formatting from
the RTF documents is NOT maintained when pasted. I think the normal.dot
settings are used.
Following is a sample of the VB.NET code being used:
'Retrieve source RTF document contents.
Source.Activate()
Source.Selection.HomeKey(Word.WdUnits.wdStory)
Source.Selection.WholeStory()
Source.Selection.Copy()
'Paste into destination document.
Destination.Activate()
Destination.Selection.PasteAndFormat(Word.WdRecoveryType.wdFormatOriginalFormatting)
As you can see, I am using the "wdFormatOriginalFormatting" flag but it
doesn't seem to matter.
Curiously, if I set a breakpoint on the
Destination.Selection.PasteAndFormat() line, select the destination
document and perform a CTRL-V, I see the same incorrect formatting
issue.
If I then open a new instance of Word and perform a CTRL-V to copy the
same data from the Clipboard to the newly created document, the
formatting is correct.
Can someone out there please tell me what the heck I'm doing wrong?
-John