Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I insert and remove bullet points using C# with Word

Posted on 2009-04-05
3
Medium Priority
?
9,194 Views
Last Modified: 2012-05-06
Hi,
I am using C# to automatically populate text in a Word Document. I need a certain paragraph to have bullet points but the next paragraph revert to normal text. I can insert the bullet points but cannot remove them. I am using the following code:


 Object oTrue = true;
 Object oFalse = false;
 Object oTemplatePath = @"C:\SampleTemplate.dotx";
Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document oDoc = new Microsoft.Office.Interop.Word.Document();
Microsoft.Office.Interop.Word.Paragraph oPara1;

oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);

oPara1.Range.ParagraphFormat.LeftIndent = -1;
oPara1.Range.ListFormat.ApplyBulletDefault(ref oMissing);
oPara1.Range.Text = "Sample Text that has a preceding bullet point";

oPara1.Range.InsertParagraphAfter();

//Here I need to remove the bullet point on the next paragraph


Any help would be greatly appreciated.

Thanks
David
0
Comment
Question by:dvscie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Accepted Solution

by:
DanSo1 earned 1000 total points
ID: 24076895
Hi
You can use RemoveNumbers method:

oPara1.Range.ListFormat.RemoveNumbers(ref oNumberType);

oNumberType is wdNumberParagraph

Regards
  Danso

0
 
LVL 23

Expert Comment

by:irudyk
ID: 24076957
Try the following:
oPara1.Range.InsertParagraphAfter();

//Here I need to remove the bullet point on the next paragraph

oPara1.Range.ListFormat.RemoveNumbers();
0
 

Author Closing Comment

by:dvscie
ID: 31566854
Thank you for your solution - it was very much appreciated and resolved my problem!
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question