2012-01-23 4 views
0

est-il un moyen de créer des styles dans PowerPoint VSTO au format texte, quelque chose semblable à ce qui est possible avec document Word:Création de styles personnalisés

// document is of type Microsoft.Office.Interop.Word.Document 
Style sectionHeadingExt = document.Styles.Add("myStyle"); 
sectionHeadingExt.set_BaseStyle(SectionHeadingInt); 
sectionHeadingExt.Font.Size = 14; 
sectionHeadingExt.Font.Color = WdColor.wdColorBlack; 
sectionHeadingExt.Font.Bold = (int)MsoTriState.msoFalse; 
sectionHeadingExt.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceMultiple; 
sectionHeadingExt.ParagraphFormat.LineSpacing = _application.LinesToPoints((float)1.11); 
sectionHeadingExt.ParagraphFormat.SpaceBefore = 0; 
sectionHeadingExt.ParagraphFormat.SpaceAfter = 0; 

Je dois créer un onglet personnalisé, ajoutez un bouton là et quand ce bouton est cliqué, je dois formater le paragraphe sélectionné en conséquence:

GetCurrentParagraph().set_Style("myStyle"); 

Je l'ai fait dans Word AddIn, mais est-il possible avec PowerPoint? Aussi, je ne peux pas voir Styles/Changer les styles options dans PowerPoint (dans Word, ils apparaissent sur l'onglet Accueil).

Répondre

1

Word a une fonction Styles; PowerPoint ne fonctionne pas, il n'est donc pas possible de le faire de la même manière que dans Word. Vous aurez probablement besoin d'écrire du code pour récupérer et stocker les différents attributs qui déterminent à quoi ressemble un morceau de texte (nom de la police, taille, gras/italique, interligne, espacement des paragraphes, couleur, etc.) et le code appliquer les attributs stockés à un autre texte. (Et concernant votre commentaire de suivi) ... Oui.

Dim oRng As TextRange 

' Is text selected? If so, work with it, else quit: 

With ActiveWindow.Selection 
If .Type = ppSelectionText Then 
    Set oRng = .TextRange 
Else 
    Exit Sub 
End If 
End With ' Selection 

With oRng 
    With .Font 
     .Bold = True 
     .Size = 24 ' point 
     ' and so on 
    End With 
End With ' oRng 
+0

Merci. Existe-t-il un moyen d'accéder à quelque chose comme le texte sélectionné ou le paragraphe actif dans la diapositive PowerPoint? Et aussi comment appliquer le style (comme gras, indentation etc) à ce texte? – dragonfly

Questions connexes