![]() |
#1
|
|||
|
|||
![]()
I am trying to paste Bulleted lists from RTF document to Word 2010
programatically using vb.net, but the bulleted lists are getting pasted as normal text. Please advise as to how to retain bulleted lists while pasting from RTF document to Word 2010. Any code snippets would be of great help. |
#2
|
||||
|
||||
![]()
Which code are you using? Are you sure that you are pasting in rich text format (as opposed to plain text format)?
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#3
|
|||
|
|||
![]()
pWrdDoc.Sections.Last.Range.PasteAndFormat(Word.WdRecoveryType.wdFormatOriginalFormatting)
That's the code i am using to paste content from RTF to Word 2010, where pWrdDoc is a instance of Word document. |
#4
|
||||
|
||||
![]()
Have you tested the PasteSpecial method instead?
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#5
|
|||
|
|||
![]()
I tested by using the below mentioned Pastespecial method, but it
didn't work as expected. I can see still find bulleted lists missing in word. pWrdDoc.Sections.Last.Range.PasteSpecial(, , , , WdPasteDataType.wdPasteRTF, , ) |
#6
|
||||
|
||||
![]()
Which application is opening the RTF document? Maybe it doesn't support number formatting.
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#7
|
|||
|
|||
![]()
I don't think that the application has an issue in supporting Number formatting.I tried using this code and it pastes bulleted lists from RTF to word as expected, but page numbering is messed up.pWrdDoc.Sections.Last.Range.Paste()If i use pWrdDoc.Sections.Last.Range.PasteAndFormat(Word.Wd RecoveryType.wdFormatOrginalFormatting) , Pagenumbering issues are fixed but Bulledted lists is not pasted properly, it's seen as simple text.I am struck with this issue.
|
#8
|
||||
|
||||
![]()
Which application is it?
I see no problem copying from an RTF file to a Word document, if both documents are opened in word.
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#9
|
|||
|
|||
![]()
I tried this code and i am able to see bulleted lists after pasting the content onto word.
PwrdPasteDoc.Sections.Last.Range.PasteSpecial(, , , , DataType:=Word.WdPasteDataType.wdPasteRTF) With PwrdPasteDoc.Styles("Normal").Font .Name = "Arial" .Size = 10 End With But, I can find extra spacing between the lines after pasting the data. How do you avoid extra spacing between the lines ? Any code snippet would be great. |
#10
|
||||
|
||||
![]()
It seems as if you have to change the Line Spacing and Spacing Before/After for the style. Something like this:
Code:
With PwrdPasteDoc.Styles("Normal") .Font.Size = 10 .Font.Name = "Arial" .ParagraphFormat.LineSpacingRule = 0 'single line spacing .ParagraphFormat.SpaceBefore = 0 .ParagraphFormat.SpaceAfter = 0 End With
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#11
|
|||
|
|||
![]()
I have implemented the code suggested by you, but it doesn't resolve the spacing issue.
Actually, i can find unwanted spacing between each bullet inside the bulleted lists when pasted to word. i have attached the screenshot for your reference. How can i avoid these unwanted spaces between bullets in bulleted lists. Any code snippets would be of great help. |
#12
|
||||
|
||||
![]()
The "spacing" could be blank paragraphs. Display nonprinting marks by clicking the ¶ button on the Home tab. If you see paragraph marks (¶) between the bulleted items, then you have blank paragraphs, which you should delete.
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#13
|
|||
|
|||
![]()
I included additional conditions to supress the blank spaces between bullets.
.SpaceBeforeAuto =False .SpaceAfterAuto=False And it is working perfect now. Thanks for your suggestions and technical assistance. ![]() |
#14
|
||||
|
||||
![]()
I'm glad you got it sorted!
I tend to forget about those "auto spacing" options (obviously). :-)
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
WDFormatOriginalFormatting does not retain formatting when content pasted from RTF | ramsgarla | Word Tables | 1 | 10-05-2012 02:35 AM |
![]() |
ramsgarla | Word | 3 | 10-01-2012 03:52 AM |
Bulleted Lists in Notebook Layout | beatles1291 | Word | 0 | 01-25-2012 08:52 PM |
Bulleted and Numbered Lists | peret944 | Word | 0 | 03-25-2011 01:08 PM |
![]() |
mhartman09 | Word | 2 | 12-10-2010 12:18 PM |