Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Add right justfied tab to a textframe via VBA (Office 2007)

19 views
Skip to first unread message

Dale Fye

unread,
Nov 23, 2009, 3:31:02 PM11/23/09
to
I'm using Access to build a series of data driven slides, mostly textframes
with special formatting. With help from a variety of individuals in the
PowerPoint community, I'm almost done. However, one of my text frames will
include some text, followed by a date on each row. What I would like to do,
is be able to embedd tabs in the text string that I am passing to a function.
The function creates the textframe and does the formatting.

So, how do I add a right justified tab formatting to the text frame, so that
the tabs that are embedded in the text between the events and the dates will
result in a left justified event names and right justified event dates.

One additional question. Is there any way (other than creating a table) to
change the background color of every other row of text in the same text
frame? I know I could build multiple textframes that only handle a single
row each, but I'm just wondering

----
Dale

Steve Rindsberg

unread,
Nov 23, 2009, 10:46:36 PM11/23/09
to
In article <D0A37F89-83BA-4DE5...@microsoft.com>, Dale Fye wrote:
> I'm using Access to build a series of data driven slides, mostly textframes
> with special formatting. With help from a variety of individuals in the
> PowerPoint community, I'm almost done. However, one of my text frames will
> include some text, followed by a date on each row. What I would like to do,
> is be able to embedd tabs in the text string that I am passing to a function.
> The function creates the textframe and does the formatting.
>
> So, how do I add a right justified tab formatting to the text frame, so that
> the tabs that are embedded in the text between the events and the dates will
> result in a left justified event names and right justified event dates.

Sub StopThatTab()
Dim oSh As Shape
Dim x As Long

' for demo purposes, we'll use the currently selected
' shape. so be sure to select one. ;-)
Set oSh = ActiveWindow.Selection.ShapeRange(1)

With oSh.TextFrame.Ruler
' Delete any existing tabstops
For x = .TabStops.Count To 1 Step -1
.TabStops(x).Clear
Next

' Now add right tabs at 1, 2 and 4 inches
' Measurements are in points, 72 to the inch
.TabStops.Add ppTabStopRight, 72
.TabStops.Add ppTabStopRight, 144
.TabStops.Add ppTabStopRight, 288
End With
End Sub


> One additional question. Is there any way (other than creating a table) to
> change the background color of every other row of text in the same text
> frame? I know I could build multiple textframes that only handle a single
> row each, but I'm just wondering

You could add rectangles behind every other row of text.

You'd work with the textrange's .Lines or .Paragraphs object, whichever is more
appropriate.

This is nowhere close but it'll get you started. It puts a rectangle around
each line of text. You'll need to use z-order to send the rectangles behind the
text and will probably want to adjust the numbers a bit to account for line
spacing.

Sub Thing()
Dim oSh As Shape
Dim x As Long
Dim oSl As Slide

Set oSh = ActiveWindow.Selection.ShapeRange(1)
Set oSl = ActivePresentation.Slides(1)

With oSh.TextFrame.TextRange
For x = 1 To .Lines.Count
oSl.Shapes.AddShape msoShapeRectangle, _
oSh.Left, .Lines(x).BoundTop, oSh.Width, .Lines(x).BoundHeight
Next
End With
End Sub

==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/


Dale Fye

unread,
Nov 24, 2009, 8:03:56 PM11/24/09
to
Thanks, Steve!

"Steve Rindsberg" <ab...@localhost.com> wrote in message
news:VA.000054b...@localhost.com...

0 new messages