D
ddobier
Hello,
I'm creating a PPT with info in an Excel worksheet. Everything works great
except when I add text to a textrange I can't get the indent level to work
correctly. It only applies my indent level to the last line in the
textrange. As a result, if I call my function once, the indent works fine.
If I call the function again, to add an additional line to my textrange, the
line which had a previous indentlevel = 2 reverts to an indentlevel = 1 and
the newly added line takes on the correct indentlevel = 2. If I explicitly
state which lines I want indented, everything works fine. (i.e
..TextFrame.textrange.Lines(2, 1).IndentLevel = 2
..TextFrame.textrange.Lines(3, 1).IndentLevel = 2
)
In my function I try to pass in the starting line number and if I do this,
it doesn't work. (i.e.
..Lines(currentlinenum, 1).IndentLevel = 2
)...where currentlinenum is the number of the last line in the textrange
Any ideas? I'm going out of my mind trying to figure this seeminly simple
thing out. Here's my function if it helps:
'where I'm calling my function:
Call addPhaseIInterfaceText(Worksheets("Setup").Range("A25"),
Worksheets("Setup").Range("B25"), _
Worksheets("Setup").Range("C25"),
Worksheets("Setup").Range("D25"))
Call addPhaseIInterfaceText(Worksheets("Setup").Range("A26"),
Worksheets("Setup").Range("B26"), _
Worksheets("Setup").Range("C26"),
Worksheets("Setup").Range("D26"))
the function:
Private Function addPhaseIInterfaceText(InterfaceType As String, PhaseI As
String, PhaseINew As String, _
PhaseII As String)
Dim currentlinenum As Integer
' made a public variable Dim additionalInterfaces As String
'additionalInterfaces = "Additional Recommended Interfaces"
objPPT.Presentations(1).Slides("CurrentInterfaces").Select
Set mydocument = objPPT.Presentations(1).Slides("PhaseIInterfaces")
If PhaseI = "YES" Then
If PhaseINew = "YES" Then
With mydocument.Shapes("PhaseIInterfacesText").TextFrame.textrange
'MsgBox .Text
.Text = .Text & Chr(13) & InterfaceType
'MsgBox .Text
currentlinenum =
mydocument.Shapes("PhaseIInterfacesText").TextFrame.textrange.Lines.Count
MsgBox "Line to be indented=" & str(currentlinenum)
.Lines(currentlinenum, 1).IndentLevel = 2
MsgBox "indented"
End With
Else
MsgBox "else"
additionalInterfaces = additionalInterfaces & Chr(13) &
InterfaceType
End If
Else
Exit Function
End If
End Function
Thanks in advance.
I'm creating a PPT with info in an Excel worksheet. Everything works great
except when I add text to a textrange I can't get the indent level to work
correctly. It only applies my indent level to the last line in the
textrange. As a result, if I call my function once, the indent works fine.
If I call the function again, to add an additional line to my textrange, the
line which had a previous indentlevel = 2 reverts to an indentlevel = 1 and
the newly added line takes on the correct indentlevel = 2. If I explicitly
state which lines I want indented, everything works fine. (i.e
..TextFrame.textrange.Lines(2, 1).IndentLevel = 2
..TextFrame.textrange.Lines(3, 1).IndentLevel = 2
)
In my function I try to pass in the starting line number and if I do this,
it doesn't work. (i.e.
..Lines(currentlinenum, 1).IndentLevel = 2
)...where currentlinenum is the number of the last line in the textrange
Any ideas? I'm going out of my mind trying to figure this seeminly simple
thing out. Here's my function if it helps:
'where I'm calling my function:
Call addPhaseIInterfaceText(Worksheets("Setup").Range("A25"),
Worksheets("Setup").Range("B25"), _
Worksheets("Setup").Range("C25"),
Worksheets("Setup").Range("D25"))
Call addPhaseIInterfaceText(Worksheets("Setup").Range("A26"),
Worksheets("Setup").Range("B26"), _
Worksheets("Setup").Range("C26"),
Worksheets("Setup").Range("D26"))
the function:
Private Function addPhaseIInterfaceText(InterfaceType As String, PhaseI As
String, PhaseINew As String, _
PhaseII As String)
Dim currentlinenum As Integer
' made a public variable Dim additionalInterfaces As String
'additionalInterfaces = "Additional Recommended Interfaces"
objPPT.Presentations(1).Slides("CurrentInterfaces").Select
Set mydocument = objPPT.Presentations(1).Slides("PhaseIInterfaces")
If PhaseI = "YES" Then
If PhaseINew = "YES" Then
With mydocument.Shapes("PhaseIInterfacesText").TextFrame.textrange
'MsgBox .Text
.Text = .Text & Chr(13) & InterfaceType
'MsgBox .Text
currentlinenum =
mydocument.Shapes("PhaseIInterfacesText").TextFrame.textrange.Lines.Count
MsgBox "Line to be indented=" & str(currentlinenum)
.Lines(currentlinenum, 1).IndentLevel = 2
MsgBox "indented"
End With
Else
MsgBox "else"
additionalInterfaces = additionalInterfaces & Chr(13) &
InterfaceType
End If
Else
Exit Function
End If
End Function
Thanks in advance.