OlympicNigel
asked on
MS Word Paragraph Formatting
Hi,
I am trying to create a Word document through VB .net and have managed to create the documents and add content through code, however I have become stuck with one aspect.
I have some content which I am trying to place into the document by pasting rtf data from the clipboard.
The data always goes into the document aligned to the very left hand side of the document.
How can I get the pasted data (RTF Text) to align say 2 tab stops in from the left?
I have tried oPara.IndentCharWidth(2) and oPara.LefIndent=(2) and numerous other combinations to no effect.
Can anyone offer any advise or code samples in VB Net?
Im using VS 2008 and Word 2010
Thanks in advance
I am trying to create a Word document through VB .net and have managed to create the documents and add content through code, however I have become stuck with one aspect.
I have some content which I am trying to place into the document by pasting rtf data from the clipboard.
The data always goes into the document aligned to the very left hand side of the document.
How can I get the pasted data (RTF Text) to align say 2 tab stops in from the left?
I have tried oPara.IndentCharWidth(2) and oPara.LefIndent=(2) and numerous other combinations to no effect.
Can anyone offer any advise or code samples in VB Net?
Im using VS 2008 and Word 2010
Thanks in advance
ASKER
I tried both these:
oPara = oDoc.Content.Paragraphs.Ad d
oPara.Range.Paste()
oPara.LeftIndent = oPara.TabStops(2).Position
oPara.Range.InsertParagrap hAfter()
and
oPara = oDoc.Content.Paragraphs.Ad d
oPara.LeftIndent = oPara.TabStops(2).Position
oPara.Range.Paste()
oPara.Range.InsertParagrap hAfter()
In both cases the pasted content remains aligned to the very left of the document.
oPara = oDoc.Content.Paragraphs.Ad
oPara.Range.Paste()
oPara.LeftIndent = oPara.TabStops(2).Position
oPara.Range.InsertParagrap
and
oPara = oDoc.Content.Paragraphs.Ad
oPara.LeftIndent = oPara.TabStops(2).Position
oPara.Range.Paste()
oPara.Range.InsertParagrap
In both cases the pasted content remains aligned to the very left of the document.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok this gives me the pasted text at the beginning of the document. But it is indented so that is a step further.
How would I make this work so that it follows on from a previously created paragraph. The number of paragraphs will vary and not be the same.
Also, the firt methods, (and the ones previously used by me) worked with the oPara.Range.Text "Text" line but not when the Range is the pasted contents of the clipboard. Why is that?
How would I make this work so that it follows on from a previously created paragraph. The number of paragraphs will vary and not be the same.
Also, the firt methods, (and the ones previously used by me) worked with the oPara.Range.Text "Text" line but not when the Range is the pasted contents of the clipboard. Why is that?
ASKER
GrahamSkan:
I managed to crack it from your second answer. Thanks
I managed to crack it from your second answer. Thanks
ASKER
Answer required some further investigation but provided the roots to the solution
Sorry, I went out shortly after my last comment. Glad to here that you have now sorted it. Good luck with the project.
It looks obvious now, but I missed it last night; in my comment above, 'here' should have been 'hear'.
Open in new window