简体   繁体   中英

How to add bullets in powerpoint

Look at this screenshot: http://imagizer.imageshack.us/a/img844/4241/at9t.jpg ... This is from Powerpoint. There you can change your bullets. But I create a Powerpoint add-in and I need to change bullets in c#.

Here is how to add first bullet (black small circle) but I would like to add others (white big circle or others). How can I do this?

char myCharacter = (char)9675; // white circle unicode
textRange.Paragraphs(i).ParagraphFormat.Bullet.Character = myCharacter;
textRange.Paragraphs(i).ParagraphFormat.Bullet.Type = PpBulletType.ppBulletUnnumbered;

Here is the webpage of microsoft, but I don´t see anything useful for me. http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.ppbullettype(v=office.14).aspx

Have you tried BulletFormat.Character ?

Returns or sets the Unicode character value that is used for bullets in the specified text. Read/write.

int Character { get; set; }

If you want the white circle icon the unicode is 9675 and you can simply cast the number to a char as this example shows or the concept code below.

char myCharacter= (char) 9675; // white circle unicode
textRange.Paragraphs(i).ParagraphFormat.Bullet.Character = myCharacter;

Full-blown example

Since it doesn't work at your end, I have created an example that gets the job done. Please let me know if you have any further questions.

// Create the Presentation File
Application pptApplication = new Application();
Presentation pptPresentation = pptApplication.Presentations.Add(MsoTriState.msoTrue);
CustomLayout customLayout = pptPresentation.SlideMaster.CustomLayouts[PpSlideLayout.ppLayoutText];

// Create new Slide
var slides = pptPresentation.Slides;
var slide = slides.AddSlide(1, customLayout);

// Add title
slide.Shapes[1].TextFrame.TextRange.Text = "Title of slide.com";

// Add items to list
var bulletedList = slide.Shapes[2]; // Bulleted point shape
var listTextRange = bulletedList.TextFrame.TextRange;
listTextRange.Text = "Content goes here\nYou can add text\nItem 3";

// Change the bullet character
var format = listTextRange.Paragraphs().ParagraphFormat;
format.Bullet.Character = (char)9675;

pptPresentation.SaveAs(@"c:\temp\fppt.pptx", PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
pptPresentation.Close();
pptApplication.Quit();

you can also use

textRange.ParagraphFormat.Bullet.Character = '○';

Where '○' (used in above line) can be changed and even can use bullets not defined in powerpoint

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM