Use VBA in power point to set bullets - vba

I'm trying to set bullet points in Power Point VBA. I have the following working code, but it provides numbered bullets. I only want standard bullets.
Any help would be appreciated:
newRow.Cells(8).Shape.TextFrame.TextRange.Text = inputText ' Note this text is multi-line and of type string.
newRow.Cells(8).Shape.TextFrame.TextRange.ParagraphFormat.Bullet.Style = ppBulletCircleNumWDBlackPlain
Any help would be appreciated.
Thank you

Try this to maintain indentation of subsequent lines:
newRow.Cells(8).Shape.TextFrame.TextRange.ParagraphFormat.Bullet.Character = 8226

You need to change bullet type with BulletFormat.Type property:
Dim tr As TextRange
Set tr = newRow.Cells(8).Shape.TextFrame.TextRange
'change to standard unordered bullet
tr.ParagraphFormat.Bullet.Type = ppBulletUnnumbered
'align bullets
tr.ParagraphFormat.Alignment = ppAlignLeft

Related

Is there a way to change font color of portion of a string in VBA userform's label?

I'm trying to change the color of a portion of a string that is loaded into userform's label based on certain conditions. My attempt is to find the starting character and length of the string I want to format by using instr function and then loop through individual characters and change their .forecolor property.
startpoint = InStr(showformula, ListBoxValue)
endpoint = startpoint + Len(ListBoxValue)
For i = startpoint To endpoint
LabelMain.Characters(i).ForeColor = RGB(255, 0, 0)
Next i
Unfortunately, I am getting error on the LabelMain.Characters(i).ForeColor = RGB(255, 0, 0) as it looks like I cannot select individual characters in VBA's label userform.
Is there another way to change the font color of only portion of the label's caption?
Thank you!
Nope. If it's just a one off can just split your text into multiple labels and sit them on top of each other.
If your wanting something programmtic it would be a lot trickier, only solution I can think of would be to :
Create array of the widths of all characeters in your font set.
Calculate distance from edge of label where highlight text starts
Replace text with spaces equal to highlight text lenght
Create a new label over the top in correct position based on new distance.
set Lbl = MyForm.Contorls.Add("Forms.Label.1", "MyNewLabelName",true)
'Set properties of the lbl

Align a text frame when creating a ppt from access vba

I'm trying to align a text frame when creating a ppt from access. Alignment control is available from excel vba but I'm struggling to find this in access.
Here is an example of the creation of a textbox in powerpoint from access vba. I have control of the font size and such but I cannot locate the alignment for the textbox.
' Program data
Dim tb_ProgramData As Shape
Set tb_ProgramData = pptCurrentSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, Left:=68.399, Top:=51.12, Width:=187.2, Height:=18.72)
tb_ProgramData.TextFrame.TextRange.Text = rs.Fields(27) + " Program: " + rs.Fields(29)
tb_ProgramData.TextFrame.TextRange.Font.Size = 9
tb_ProgramData.TextFrame.TextRange.Font.Bold = msoTrue
The only thing close is a paragraph alignment but it has no effect...
tb_Title.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
Any help would be appreciated... regards,
Good grief.. I found it under the text effects.
tb_SystemClass.TextEffect.Alignment = msoTextEffectAlignmentRight
and if you wish to select the textbox from the list of shapes then...
pptCurrentSlide.Shapes.Range("tb_SystemClass").TextEffect.Alignment = msoTextEffectAlignmentRight

Underline property of textbox not working like the others

I simply want to underline some text in a worksheet textbox using VBA, from a specific character to another. It should be extremely simple, and I can do it without problem with Bold and Italic.
I have the following sub
Sub ew()
Dim txt1 As Shape
Set txt1 = Sheet1.Shapes("txt_1")
txt1.TextFrame.Characters.Text = "Bold and Underline this"
txt1.TextFrame.Characters.Font.Bold = True
txt1.TextFrame.Characters.Font.Italic = True
txt1.TextFrame.Characters.Font.Underline = True
End Sub
The code fails on the last line, which is extremely strange because it worked for the 2 previous lines. the error (1004) says something like "Impossible to define the Underline function of the Font property".
To recreate the problem, take my sub to a new Excel document and create a textbox named "txt_1", that's all you need to run it.
If anyone has any idea why it fails, please help!
You need to define the Underline style. Taking your last line
txt1.TextFrame.Characters.Font.Underline = xlUnderlineStyleSingle
Use TextFrame2 for underline
txt1.TextFrame2.TextRange.Font.UnderlineStyle = msoUnderlineSingleLine

Word VSTO - Change the absolute positions' type?

I use the following VB.NET (VSTO) code to add a shape in MS-Word,
Dim app As Word.Application = Globals.ThisAddIn.Application
Dim doc As Word.Document = app.ActiveDocument
Dim left As Single = CSng(Convert.ToDouble(app.Selection.Information(Word.WdInformation.wdHorizontalPositionRelativeToPage)))
Dim top As Single = CSng(Convert.ToDouble(app.Selection.Information(Word.WdInformation.wdVerticalPositionRelativeToPage)))
Dim shape As Word.Shape = doc.Shapes.AddShape(1, left, top, 225.1F, 224.5F)
shape.Fill.BackColor.RGB = ColorTranslator.ToOle(Color.Transparent)
shape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
shape.Fill.Transparency = 0.0F
shape.Line.Transparency = 0.0F
shape.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
What this code does is, it adds a rectangle shape at cursor point and makes it transparent (both background and line).
Now I like to change the absolute positions' type. To explain further, when you select the rectangle shape, then if you select the Ribbon tab Format > Position > More Layout Options... as shown in the image below,
It will open the following dialog,
In the above dialog I like to change Column and Paragraph marked by the red rectangles into the type Margin. How to do this by code?
Word provides a Macro recorder. You may use it to get the code generated for you in the background. Thus, you will find what properties and methods exactly should be used to get the job done. See Record or run a macro for more information.
The solution to this was solved in the link below,
https://social.msdn.microsoft.com/Forums/vstudio/en-US/e69584d7-24fe-4396-9a82-26b7dae02584/word-vsto-change-the-absolute-positions-type?forum=vsto

How to Find Bullet List and Format Bullets (VBA _ Word Documnet)

I'm trying to find instances of a bullet list in a document then change the bullet type and bullet size.
I was trying to change the following style code so that it would use a bullet type that is formatted to the size and type of bullet i want but I can't seem to figure out the correct object to call or the correct properties to assign.
I have added a custom bullet type and size to the bullet list it is in position nine(9) of the list, if that helps.
I was tried to change the "list Paragraph" to a bullet type but kept keeping an error.
Sub BulletStyle ()
Dim oBull As Word.Paragraph
For Each oBull In ActiveDocument.Paragraphs
If oBull.Range.ListFormat.ListType = _
WdListType.wdListBullet Then
oBull.Style = "List Paragraph"
End If
Next
End Sub
Create a Custom Style that is set to the bullet you want to change it to and make sure format is set to "Numbering" in the style definition.
Then simply change the following line of code
oBull.Style = "List Paragraph"
To the name of your custom style:
oBull.Style = "MyCustomStyle"
When you create your Custom Style make sure to set Format as Numbering.