How can I get children features of selected feature using CATIA macro for part simplification (Inactivate edgefillet, chamfer)? - vba

I m trying to inactivate the edge fillet and chamfer feature to simplify the CATIA model.
I made the macro code as follow.
However, obiously, if the other features refer the fillet or chamfer, the part cannot be updated.
Thus, I want to inactivate the all children features, but I cannot find how to get the children relationship of selected feature.
Please give me help or insight to solve this problem
Thank you for your help
Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
If Err.Number = 0 Then
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
selection1.Search "Name=*fillet*,all"
If selection1.Count = 0 Then
MsgBox "No fillet features"
Else
For i = 1 To selection1.Count
part1.Inactivate (selection1.Item2(i).Value)
Next 'i
'part1.Update
End If
Dim selection2 As Selection
Set selection2 = partDocument1.Selection
selection2.Search "Name=*chamfer*,all"
If selection2.Count = 0 Then
MsgBox "No chamfer features"
Else
For j = 1 To selection2.Count
part1.Inactivate (selection2.Item2(j).Value)
Next 'j
'part1.Update
End If
part1.Update
MsgBox ( tot_f_c_num & " features are inactivated.")
Else
MsgBox "Not a part document! Open a single part document."
End If
End Sub

#Shrotter I modified my macro as follow; it seems to work well at this time, but may have problem ::
Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
If Err.Number = 0 Then
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
selection1.Search "Name=*fillet*,all"
If selection1.Count = 0 Then
MsgBox "No fillet features"
Else
For i = 1 To selection1.Count
part1.Inactivate (selection1.Item2(i).Value)
Next 'i
End If
Dim selection2 As Selection
Set selection2 = partDocument1.Selection
selection2.Search "Name=*chamfer*,all"
If selection2.Count = 0 Then
MsgBox "No chamfer features"
Else
For j = 1 To selection2.Count
part1.Inactivate (selection2.Item2(j).Value)
Next 'j
End If
Dim selection3 As Selection
Set selection3 = partDocument1.Selection
selection3.Search "Name=*,all"
For k = 1 To selection3.Count
On Error Resume Next
part1.UpdateObject (selection3.Item2(k).Value)
If Err.Number <> 0 Then
part1.Inactivate (selection3.Item2(k).Value)
End If
Next 'k
Else
MsgBox "Not a part document! Open a single part document."
End If
End Sub

Related

Remove No Element Publication from Catia

I wanted to remove the broken publications which are having No Element Status only highlighted in yellow as shown below.
Below is my code its not giving full result. please help me to resolve this.
Sub CATMain()
Set CATIA = GetObject(, "CATIA.APPLICATION")
Set oSelection = CATIA.ActiveDocument.Selection
oSelection.Search "CATAsmSearch.Part,all"
For i = 1 To oSelection.Count
Dim num_of_publ_existing As Integer
num_of_publ_existing = oSelection.Item(i).Value.Publications.Count
ReDim aa(num_of_publ_existing)
For k = 1 To num_of_publ_existing
PubName = oSelection.Item(i).Value.Publications.Item(k).Name
Set pubRef = oSelection.Item(i).Value.Publications.Item(PubName).Valuation
If pubRef.DisplayName <> "" Then
aa(k - 1) = PubName
Debug.Print PubName
Debug.Print pubRef.DisplayName
End If
Next
For j = 0 To num_of_publ_existing
oSelection.Item(i).Value.Publications.Remove (aa(j))
Next
Next
oSelection.Clear
End Sub

VBA Powerpoint 2013: change presentation language including SmartArt objects

I can not find a way to change by VBA script the language in SmartArt objects in Powerpoint 2013.
I've seen PowerPoint 2007 - Set language on tables, charts etc that contains text but it does not work for SmartArt objects.
Any idea how I could do this?
Many thanks.
You need to access the Nodes (or GroupItems) of the SmartArt object like this:
Sub SwitchSmartArtLanguage(oSA As SmartArt)
Dim oNode As SmartArtNode
With oSA
For Each oNode In .Nodes
oNode.TextFrame2.TextRange.LanguageID = msoLanguageIDEnglishUK
Next
End With
End Sub
This is the code I finally use to change the language including SmartArts:
Sub SetLangUS()
Call changeLanguage(ActivePresentation, "US")
End Sub
Sub SetLangDE()
Call changeLanguage(ActivePresentation, "DE")
End Sub
Private Function changeLanguage(oPres As Presentation, langStr As String)
' Reference http://stackoverflow.com/questions/4735765/powerpoint-2007-set-language-on-tables-charts-etc-that-contains-text
' https://support.microsoft.com/en-us/kb/245468
On Error Resume Next
Dim r, c As Integer
Dim oSlide As Slide
Dim oNode As SmartArtNode
Dim oShape, oNodeShape As Shape
Dim lang As String
'lang = "Norwegian"
'Determine language selected
If langStr = "US" Then
lang = msoLanguageIDEnglishUS
ElseIf langStr = "UK" Then
lang = msoLanguageIDEnglishUK
ElseIf langStr = "DE" Then
lang = msoLanguageIDGerman
ElseIf langStr = "FR" Then
lang = msoLanguageIDFrench
End If
'Set default language in application
oPres.DefaultLanguageID = lang
'Set language in each textbox in each slide
For Each oSlide In oPres.Slides
For Each oShape In oSlide.Shapes
'Check first if it is a table
If oShape.HasTable Then
For r = 1 To oShape.Table.Rows.Count
For c = 1 To oShape.Table.Columns.Count
oShape.Table.Cell(r, c).Shape.TextFrame.TextRange.LanguageID = lang
Next
Next
ElseIf oShape.HasSmartArt Then
For Each oNode In oShape.SmartArt.AllNodes
oNode.TextFrame2.TextRange.LanguageID = lang
Next
Else
oShape.TextFrame.TextRange.LanguageID = lang
For c = 0 To oShape.GroupItems.Count - 1
oShape.GroupItems(c).TextFrame.TextRange.LanguageID = lang
Next
End If
Next
Next
' Update Masters
For Each oShape In oPres.SlideMaster.Shapes
oShape.TextFrame.TextRange.LanguageID = lang
Next
For Each oShape In oPres.TitleMaster.Shapes
oShape.TextFrame.TextRange.LanguageID = lang
Next
For Each oShape In oPres.NotesMaster.Shapes
oShape.TextFrame.TextRange.LanguageID = lang
Next
' MsgBox
MsgBox "Presentation Language was changed to " & langStr & ".", vbOKOnly, "SetLanguage"
End Function

Listbox - Unable to recognize blank value

I have two listboxes in my script which are populated with Month values and Year values. If the listbox is populated with values, it writes them to a worksheet, whereas if they are blank, it should throw an error.
I created a test scenario where I have two blank listboxes, the code below should throw a message box advising the user to select a value before executing the script. However, VBA has a mind of its own and thinks that the list boxes are populated with values, therefore I get:
Runtime Error 1004 - Unable to get the List property of the DropDown class
Is there something wrong with the code below that I am not seeing?
Sub TestDropDown()
Dim MonthBox As DropDown, YearBox As DropDown
Dim WB As Workbook
Dim WS4 as Worksheet
Set WB = ThisWorkbook
Set WS4 = WB.Worksheets("Config")
Set MonthBox = ThisWorkbook.Worksheets("Control Sheet").DropDowns("Drop Down 8")
Set YearBox = ThisWorkbook.Worksheets("Control Sheet").DropDowns("Drop Down 9")
'Check Monthbox for values
If IsNull(MonthBox.Value) Then
MsgBox ("Select a Month before running the script")
Failvalue = 1
GoTo EndSub:
Else
WS4.Cells(2, 9).Value = MonthBox.List(MonthBox.Value)
End If
'Check Yearbox for values
If IsNull(YearBox.Value) Then
MsgBox "Please select a Year before running the script", vbExclamation
Failvalue = 1
GoTo EndSub:
Else
WS4.Cells(2, 10).Value = YearBox.List(YearBox.Value)
End If
EndSub:
If Failvalue = 0 Then
MsgBox ("Process complete")
Else
MsgBox "Process failed to complete", vbCritical
End If
WS4.Visible = xlSheetHidden
End Sub
You should check the .ListIndex instead of the .Value. If ListIndex returns zero, it means none is selected.
Try this:
Sub TestDropDown()
Dim MonthBox As DropDown, YearBox As DropDown, Failvalue As Integer
Dim WB As Workbook
Dim WS4 As Worksheet
Set WB = ThisWorkbook
Set WS4 = WB.Worksheets("Config")
Set MonthBox = ThisWorkbook.Worksheets("Control Sheet").DropDowns("Drop Down 8")
Set YearBox = ThisWorkbook.Worksheets("Control Sheet").DropDowns("Drop Down 9")
'Check Monthbox for values
'If IsNull(MonthBox.Value) Then
If MonthBox.ListIndex = 0 Then
MsgBox ("Select a Month before running the script")
Failvalue = 1
GoTo EndSub:
Else
WS4.Cells(2, 9).Value = MonthBox.List(MonthBox.ListIndex)
End If
'Check Yearbox for values
'If IsNull(YearBox.Value) Then
If YearBox.ListIndex = 0 Then
MsgBox "Please select a Year before running the script", vbExclamation
Failvalue = 1
GoTo EndSub:
Else
WS4.Cells(2, 10).Value = YearBox.List(YearBox.ListIndex)
End If
EndSub:
If Failvalue = 0 Then
MsgBox ("Process complete")
Else
MsgBox "Process failed to complete", vbCritical
End If
WS4.Visible = xlSheetHidden
End Sub
It looks like the following line of code wasn't sufficent as the listbox value wasn't equating to null.
If IsNull(YearBox.Value) then
If a ran a msgbox on the listbox value, it was returning 0 on a blank listbox so I changed the code to the following
If YearBox.Value = 0 then
This works fine!

How to modify text in Powerpoint via Excel VBA without changing style

I am trying to replace a set of tags in the text of a powerpoint slide from Excel using VBA. I can get the slide text as follows:
Dim txt as String
txt = pptSlide.Shapes(jj).TextFrame.TextRange.Characters.text
I then run through replacing my tags with the requested values. However when I set do
pptSlide.Shapes(jj).TextFrame.TextRange.Characters.text = txt
Problem: All the formatting which the user has set up in the text box is lost.
Background:
The shape object is msoPlaceHolder and contains a range of text styles including bullet points with tags which should be replaced with numbers for instance. The VBA should be unaware of this formatting and need only concern itself with the text replacement.
Can anyone tell me on how to modify the text while keeping the style set up by the user.
Thanks.
Am using Office 2010 if that is helpful.
The solution by Krause is close but the FIND method returns a TextRange object that has to be checked. Here is a complete subroutine that replaces FROM-string with TO-string in an entire presentation, and DOESN'T mess up the formatting!
Sub Replace_in_Shapes_and_Tables(pPPTFile As Presentation, sFromStr As String, sToStr As String)
Dim sld As Slide
Dim shp As Shape
Dim i As Long
Dim j As Long
Dim m As Long
Dim trFoundText As TextRange
On Error GoTo Replace_in_Shapes_and_Tables_Error
For Each sld In pPPTFile.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then ' only perform action on shape if it contains the target string
Set trFoundText = shp.TextFrame.TextRange.Find(sFromStr)
If Not (trFoundText Is Nothing) Then
m = shp.TextFrame.TextRange.Find(sFromStr).Characters.Start
shp.TextFrame.TextRange.Characters(m).InsertBefore (sToStr)
shp.TextFrame.TextRange.Find(sFromStr).Delete
End If
End If
End If
If shp.HasTable Then
For i = 1 To shp.Table.Rows.Count
For j = 1 To shp.Table.Columns.Count
Set trFoundText = shp.Table.Rows.Item(i).Cells(j).Shape.TextFrame.TextRange.Find(sFromStr)
If Not (trFoundText Is Nothing) Then
m = shp.Table.Rows.Item(i).Cells(j).Shape.TextFrame.TextRange.Find(sFromStr).Characters.Start
shp.Table.Rows.Item(i).Cells(j).Shape.TextFrame.TextRange.Characters(m).InsertBefore (sToStr)
shp.Table.Rows.Item(i).Cells(j).Shape.TextFrame.TextRange.Find(sFromStr).Delete
End If
Next j
Next i
End If
Next shp
Next sld
For Each shp In pPPTFile.SlideMaster.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then
Set trFoundText = shp.TextFrame.TextRange.Find(sFromStr)
If Not (trFoundText Is Nothing) Then
m = shp.TextFrame.TextRange.Find(sFromStr).Characters.Start
shp.TextFrame.TextRange.Characters(m).InsertBefore (sToStr)
shp.TextFrame.TextRange.Find(sFromStr).Delete
End If
End If
End If
If shp.HasTable Then
For i = 1 To shp.Table.Rows.Count
For j = 1 To shp.Table.Columns.Count
Set trFoundText = shp.Table.Rows.Item(i).Cells(j).Shape.TextFrame.TextRange.Find(sFromStr)
If Not (trFoundText Is Nothing) Then
m = shp.Table.Rows.Item(i).Cells(j).Shape.TextFrame.TextRange.Find(sFromStr).Characters.Start
shp.Table.Rows.Item(i).Cells(j).Shape.TextFrame.TextRange.Characters(m).InsertBefore (sToStr)
shp.Table.Rows.Item(i).Cells(j).Shape.TextFrame.TextRange.Find(sFromStr).Delete
End If
Next j
Next i
End If
Next shp
On Error GoTo 0
Exit Sub
Replace_in_Shapes_and_Tables_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Replace_in_Shapes_and_Tables of Module modA_Code"
Resume
End Sub
While what Steve Rindsberg said is true I think I have come up with a decent workaround. It is by no means pretty but it gets the job done without sacrificing the formatting. It uses Find functions and Error Controlling for any text box that doesn't have the variable you are looking to change out.
i = 1
Set oPs = oPa.ActivePresentation.Slides(oPa.ActivePresentation.Slides.Count)
j = 1
Do Until i > oPa.ActivePresentation.Slides.Count
oPa.ActivePresentation.Slides(i).Select
Do Until j > oPa.ActivePresentation.Slides(i).Shapes.Count
If oPa.ActivePresentation.Slides(i).Shapes(j).HasTextFrame Then
If oPa.ActivePresentation.Slides(i).Shapes(j).TextFrame.HasText Then
On Error GoTo Err1
If oPa.ActivePresentation.Slides(i).Shapes(j).TextFrame.TextRange.Find("[specific search term]") = "[specific search term]" Then
m = oPa.ActivePresentation.Slides(i).Shapes(j).TextFrame.TextRange.Find("[specific search term]").Characters.Start
oPa.ActivePresentation.Slides(i).Shapes(j).TextFrame.TextRange.Characters(m).InsertBefore ([replace term])
oPa.ActivePresentation.Slides(i).Shapes(j).TextFrame.TextRange.Find("[specific search term]").Delete
ExitHere:
End If
End If
End If
j = j + 1
Loop
j = 1
i = i + 1
Loop
Exit Sub
Err1:
Resume ExitHere
End Sub
Hope this helps!
I found the solution using the code below. It edits the notes by replacing "string to replace" with "new string". This example is not iterative and will only replace the first occurrence but it should be fairly easy to make it iterative.
$PowerpointFile = "C:\Users\username\Documents\test.pptx"
$Powerpoint = New-Object -ComObject powerpoint.application
$ppt = $Powerpoint.presentations.open($PowerpointFile, 2, $True, $False)
$ppt.Slides[3].Shapes[2].TextFrame.TextRange.Text
$ppt.Slides[3].NotesPage.Shapes[2].TextFrame.TextRange.Text
foreach($slide in $ppt.slides){
$TextRange = $slide.NotesPage.Shapes[2].TextFrame.TextRange
$find = $TextRange.Find('string to replace').Start
$TextRange.Find('string to replace').Delete()
$TextRange.Characters($find).InsertBefore('new string')
$TextRange.Text
}
$ppt.SaveAs("C:\Users\username\Documents\test2.pptx")
$Powerpoint.Quit()

Copying animation and sequence information between powerpoint shapes

I'm trying to replace all shape objects on the slide (pictures) with shape objects of another type (rectangular shape). I can delete old object and create new, but i will loose all animation information and sequence order. Is it possible to store animation information and order in timeline, and copy it to the new shape object?
Well, i have found a solution myself, hope someone could find it useful. So, it is not necessary to copy animation information from old shape to a new one, just cycle through sequence's items and replace the shape object refrence to the new shape. Like this:
On Error Resume Next
Dim shp1 As Shape 'old shape
Set shp1 = ActivePresentation.Slides(1).Shapes(3)
Dim shp2 As Shape 'new shape
Set shp2 = ActivePresentation.Slides(1).Shapes.AddPicture("c:\imgres2.jpg", msoFalse, msoTrue, 0, 0) 'it is important to create new shape before cycling through existing ones.
For i = ActivePresentation.Slides(1).TimeLine.MainSequence.count To 1 Step -1
'using "is" opeartor to compare refrences
If shp1 Is ActivePresentation.Slides(1).TimeLine.MainSequence.Item(i).Shape Then
ActivePresentation.Slides(1).TimeLine.MainSequence.Item(i).Shape = shp2
End If
Next i
shp1.Delete 'delete the old shape
Try something like this code to copy the animation into new added shape:
Sub PasteAnimationBehaviours()
Dim SHP As Shape 'for existing shape
Set SHP = ActivePresentation.Slides(1).Shapes(1)
SHP.PickupAnimation
Dim newSHP As Shape 'pasting to new shape
Set newSHP = ActivePresentation.Slides(1).Shapes.AddShape(msoShapeRectangle, 100, 100, 100, 100)
newSHP.ApplyAnimation
End Sub
Added after comment: If you only need to replace type of shape try to use something like this:
Sub ShapeSubstition()
Dim SHP As Shape 'for existing shape
'test for 1st shape in 1st slide
Set SHP = ActivePresentation.Slides(1).Shapes(1)
SHP.AutoShapeType = msoShapeRectangle 'to rectangle
SHP.AutoShapeType = msoShapeOval 'to oval
End Sub
I think it is probably easier to just use the "Animation Painter" command button to copy the animations and apply them to another object. The Animation Painter functions in the same way as the Format Painter. After you have copied the desired animations, you can reorder the individual animations using the Animation Pane.
This code shows how to copy effects from one shape to another. Select a shape before running routine "SetSourceShape" and select one or more shapes before running "PaintEffects".
Option Explicit
' resources:
' http://msdn.microsoft.com/en-us/library/aa168134(v=office.11).aspx
' http://msdn.microsoft.com/en-us/library/aa168135(office.11).aspx
' http://skp.mvps.org/ppttimeline1.htm
' uses functions from:
' https://answers.microsoft.com/en-us/msoffice/forum/all/how-to-copy-paste-animation-effect-in-powerpoint/c0f255c0-167a-4a12-ae37-1e713ee1d8df
Public MySourceShapeId As Long
Public MySourceSlideIndex As Long ' need this with shape id for unique selection
Sub SetSourceShape() ' sets source shape id value if successfull
Dim oShp As PowerPoint.Shape
Dim myShp As PowerPoint.Shape
Dim oSld As Slide
Dim oEffect As Effect
Dim HowMany As Long
Dim FoundEffect As Boolean
HowMany = 0 ' default value for nothing selected
MySourceShapeId = 0 ' default value for nothing available to copy
MySourceSlideIndex = 0
FoundEffect = False ' default value unless selected shape has any effect(s)
On Error Resume Next ' handles error when nothing is selected
HowMany = ActiveWindow.Selection.ShapeRange.Count
On Error GoTo 0 ' restore normal error handling
If HowMany = 0 Then
MsgBox "Nothing is selected"
Else
If HowMany = 1 Then
Set oShp = ActiveWindow.Selection.ShapeRange(1) ' selection on a single slide
For Each oEffect In ActiveWindow.Selection.SlideRange(1).TimeLine.MainSequence
If oEffect.Shape.Id = oShp.Id Then
MySourceShapeId = oShp.Id
MySourceSlideIndex = ActiveWindow.Selection.SlideRange(1).SlideIndex
FoundEffect = True
End If
Next
If FoundEffect Then
MsgBox "Source is selected, Slide: " & MySourceSlideIndex & ", ShapeID: " & MySourceShapeId
Else
MsgBox "Selected item has no effect(s)"
End If
Else
MsgBox "Select only one item"
End If
End If
End Sub
Sub PaintEffects()
Dim oShp As PowerPoint.Shape
Dim oEffect As Effect
Dim HowMany As Long
Dim msg As String
HowMany = 0 ' default value for nothing selected
If MySourceShapeId = 0 Then
MsgBox "No source is selected"
Exit Sub
End If
On Error Resume Next ' handles error when nothing is selected
HowMany = ActiveWindow.Selection.ShapeRange.Count
On Error GoTo 0 ' restore normal error handling
If HowMany = 0 Then
MsgBox "Nothing is selected to paint"
Else
' make sure source is not in this selection
If ActiveWindow.Selection.SlideRange(1).SlideIndex = MySourceSlideIndex Then ' check shapes
For Each oShp In ActiveWindow.Selection.ShapeRange
If oShp.Id = MySourceShapeId Then ' complain
MsgBox "Target selection must not include source item"
Exit Sub
End If
Next
End If
' OK, proceed
For Each oShp In ActiveWindow.Selection.ShapeRange
For Each oEffect In ActivePresentation.Slides(MySourceSlideIndex).TimeLine.MainSequence
If oEffect.Shape.Id = MySourceShapeId Then
Call TransferEffects(oEffect, ActiveWindow.Selection.SlideRange(1), oShp)
End If
Next
Next
End If
End Sub
Sub TransferEffects(oEffectA As PowerPoint.Effect, oSlide As Slide, oShape As PowerPoint.Shape)
Dim oEffectB As Effect
Dim IsMotion As Boolean
Set oEffectB = oSlide.TimeLine.MainSequence.AddEffect(oShape, oEffectA.EffectType)
DoEvents
On Error Resume Next
oEffectB.EffectParameters.Amount = oEffectA.EffectParameters.Amount
If Err.Number = 0 Then
Select Case oEffectA.EffectParameters.Color2.Type
Case Is = msoColorTypeScheme
oEffectB.EffectParameters.Color2.SchemeColor = oEffectA.EffectParameters.Color2.SchemeColor
Case Is = msoColorTypeRGB
oEffectB.EffectParameters.Color2.RGB = oEffectA.EffectParameters.Color2.RGB
End Select
End If
oEffectB.EffectParameters.Direction = oEffectA.EffectParameters.Direction
oEffectB.EffectParameters.FontName = oEffectA.EffectParameters.FontName
If oEffectA.EffectType <> msoAnimEffectGrowShrink Then
oEffectB.EffectParameters.Size = oEffectA.EffectParameters.Size
Else
oEffectB.Behaviors(1).ScaleEffect.ByX = oEffectA.Behaviors(1).ScaleEffect.ByX
oEffectB.Behaviors(1).ScaleEffect.ByY = oEffectA.Behaviors(1).ScaleEffect.ByY
End If
oEffectB.Timing.Duration = oEffectA.Timing.Duration
oEffectB.Timing.Accelerate = oEffectA.Timing.Accelerate
oEffectB.Timing.AutoReverse = oEffectA.Timing.AutoReverse
oEffectB.Timing.Decelerate = oEffectA.Timing.Decelerate
oEffectB.Timing.Restart = oEffectA.Timing.Restart
oEffectB.Timing.RewindAtEnd = oEffectA.Timing.RewindAtEnd
oEffectB.Timing.SmoothStart = oEffectA.Timing.SmoothStart
oEffectB.Timing.SmoothEnd = oEffectA.Timing.SmoothEnd
oEffectB.Exit = oEffectA.Exit
oEffectB.Timing.TriggerType = oEffectA.Timing.TriggerType
oEffectB.Timing.TriggerDelayTime = oEffectA.Timing.TriggerDelayTime
oEffectB.Timing.RepeatCount = oEffectA.Timing.RepeatCount
oEffectB.Timing.RepeatDuration = oEffectA.Timing.RepeatDuration
oEffectB.Timing.Speed = oEffectA.Timing.Speed
With oSlide.TimeLine.MainSequence
If oEffectA.Shape.HasTextFrame Then
Call .ConvertToAnimateBackground(oEffectB, oEffectA.EffectInformation.AnimateBackground)
Else
Call .ConvertToAnimateBackground(oEffectB, True)
End If
Select Case oEffectA.EffectInformation.AfterEffect
Case 2 ' Hide
Call .ConvertToAfterEffect(oEffectB, oEffectA.EffectInformation.AfterEffect)
Case 1 ' Dim
Call .ConvertToAfterEffect(oEffectB, oEffectA.EffectInformation.AfterEffect, oEffectA.EffectInformation.Dim)
Case 3 ' Hide on click
Call .ConvertToAfterEffect(oEffectB, oEffectA.EffectInformation.AfterEffect)
End Select
Call .ConvertToAnimateInReverse(oEffectB, oEffectA.EffectInformation.AnimateTextInReverse)
Call .ConvertToTextUnitEffect(oEffectB, oEffectA.EffectInformation.TextUnitEffect)
End With
Err.Clear
oEffectB.EffectParameters.Relative = oEffectA.EffectParameters.Relative
If Err.Number <> 0 Then
IsMotion = False
Else
IsMotion = True
End If
If IsMotion Then
oEffectB.Behaviors(1).MotionEffect.Path = oEffectA.Behaviors(1).MotionEffect.Path
On Error GoTo 0
If Sgn(Val(oEffectA.Behaviors(1).Timing.Speed)) = -1 Then
oEffectB.Behaviors(1).MotionEffect.Path = Left(oEffectA.Behaviors(1).MotionEffect.Path, 1) & " " & ReversePathInfo(Trim(Mid(oEffectA.Behaviors(1).MotionEffect.Path, 2)))
End If
End If
Exit Sub
errHandler:
If MsgBox(Err.Number & " " & Err.Description & vbCrLf & "Do you wish to continue?", vbQuestion + vbYesNo, "APP_NAME") = vbYes Then
Resume Next
End If
End Sub
Function ReversePathInfo(sPath As String) As String
Dim sItems() As String
Dim i As Integer
Dim sPositions() As String
Dim sReversedPath As String
Dim sClosedPath As String
If Not IsNumeric(Right(sPath, 1)) Then
sClosedPath = Right(sPath, 1)
sPath = Left(sPath, Len(sPath) - 1)
End If
sPath = Replace(sPath, " ", "~")
sItems = Split(sPath, "~")
ReDim sPositions(0 To UBound(sItems))
For i = LBound(sItems) To UBound(sItems)
If Left(sItems(i), 1) = "L" Then sPositions(i) = "L"
If Left(sItems(i), 1) = "C" Then sPositions(i) = "C"
If Left(sItems(i), 1) = "c" Then sPositions(i) = "c"
If Left(sItems(i), 1) = "l" Then sPositions(i) = "l"
Next i
For i = LBound(sPositions) To UBound(sPositions)
If LCase(sPositions(i)) = "c" Then
sPositions(i + 2) = sPositions(i)
sPositions(i) = ""
i = i + 2
End If
Next i
For i = UBound(sItems) To LBound(sItems) Step -1
Select Case Left(sItems(i), 1)
Case "L", "C", "c", "l"
sItems(i) = Trim(Mid(sItems(i), 2))
End Select
sReversedPath = sReversedPath & sItems(i) & " " & sPositions(i) & IIf(sPositions(i) <> "", " ", "")
Next i
ReversePathInfo = Trim(sReversedPath) & IIf(sClosedPath = "", "", " " & sClosedPath)
End Function