N
Naro25
Hello all,
I am an absolute beginner to VB and trying to write a one off program. I
wonder could someone please help me with the following simple code. My issue
is I wrote a working code to automate an animation within powerpoint i.e VBA
and need to transfer it to a user form in VB2008 so that a simple button
click will open ppt and perform the following actions.
The code to open powerpoint with a blank side and apply the ppt object
library isnt a problem, just a continuous list of error in below code about
activewindow and msoTrue/False not defined.
Any help with this matter would be extremely appreciated!
Sub ImportPicRenameLocateAnimate2()
Dim oSlide As Slide
Dim oPicture As shape
Dim shp1 As shape
Dim sResponse As String
Dim interEffect As Effect
ActiveWindow.View.GotoSlide 1
Set oSlide = ActiveWindow.Presentation.Slides(1)
Set oPicture = oSlide.Shapes.AddPicture("X.JPG", _
msoFalse, msoTrue, 1, 1, 1, 1)
' Now scale the picture to full size, with "Relative to original
' picture size" set to true for both height and width.
oPicture.ScaleHeight 1, msoTrue
oPicture.ScaleWidth 1, msoTrue
Set shp1 =
ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRectangle, 104.88,
326.75, 198.38, 102#)
With shp1
.Name = "Zone1"
.Fill.Transparency = 1#
.Line.Visible = msoFalse
.Height = 141.75
.Width = 141.75
End With
With ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Add(1)
Set interEffect = .AddEffect(shp1, msoAnimEffectFly, _
trigger:=msoAnimTriggerOnShapeClick)
interEffect.shape = oPicture
With interEffect
.EffectParameters.Direction = msoAnimDirectionLeft
.Timing.Duration = 0.5
End With
End With
With ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Add(1)
Set interEffect = .AddEffect(shp1, msoAnimEffectFly, _
trigger:=msoAnimTriggerOnShapeClick)
interEffect.shape = oPicture
With interEffect
.EffectParameters.Direction = msoAnimDirectionLeft
.Timing.Duration = 0.5
.Exit = msoTrue
End With
End With
With ActivePresentation.PageSetup
oPicture.Select
End With
'Rename image'
With ActiveWindow.Selection.ShapeRange(1)
sResponse = InputBox("new name ...", "Rename Shape", .Name)
Select Case sResponse
' blank names not allowed
Case Is = ""
Exit Sub
' no change?
Case Is = .Name
Exit Sub
Case Else
On Error Resume Next
.Name = sResponse
If Err.Number <> 0 Then
MsgBox "Unable to rename this shape"
End If
End Select
End With
With ActivePresentation.Slides(1).Shapes("X")
.Top = 0
.Left = 0
.Height = 271.75
.Width = 453.38
.Line.Visible = msoTrue
.Line.ForeColor.SchemeColor = ppForeground
.Line.BackColor.RGB = RGB(255, 255, 255)
End With
End Sub
I am an absolute beginner to VB and trying to write a one off program. I
wonder could someone please help me with the following simple code. My issue
is I wrote a working code to automate an animation within powerpoint i.e VBA
and need to transfer it to a user form in VB2008 so that a simple button
click will open ppt and perform the following actions.
The code to open powerpoint with a blank side and apply the ppt object
library isnt a problem, just a continuous list of error in below code about
activewindow and msoTrue/False not defined.
Any help with this matter would be extremely appreciated!
Sub ImportPicRenameLocateAnimate2()
Dim oSlide As Slide
Dim oPicture As shape
Dim shp1 As shape
Dim sResponse As String
Dim interEffect As Effect
ActiveWindow.View.GotoSlide 1
Set oSlide = ActiveWindow.Presentation.Slides(1)
Set oPicture = oSlide.Shapes.AddPicture("X.JPG", _
msoFalse, msoTrue, 1, 1, 1, 1)
' Now scale the picture to full size, with "Relative to original
' picture size" set to true for both height and width.
oPicture.ScaleHeight 1, msoTrue
oPicture.ScaleWidth 1, msoTrue
Set shp1 =
ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRectangle, 104.88,
326.75, 198.38, 102#)
With shp1
.Name = "Zone1"
.Fill.Transparency = 1#
.Line.Visible = msoFalse
.Height = 141.75
.Width = 141.75
End With
With ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Add(1)
Set interEffect = .AddEffect(shp1, msoAnimEffectFly, _
trigger:=msoAnimTriggerOnShapeClick)
interEffect.shape = oPicture
With interEffect
.EffectParameters.Direction = msoAnimDirectionLeft
.Timing.Duration = 0.5
End With
End With
With ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Add(1)
Set interEffect = .AddEffect(shp1, msoAnimEffectFly, _
trigger:=msoAnimTriggerOnShapeClick)
interEffect.shape = oPicture
With interEffect
.EffectParameters.Direction = msoAnimDirectionLeft
.Timing.Duration = 0.5
.Exit = msoTrue
End With
End With
With ActivePresentation.PageSetup
oPicture.Select
End With
'Rename image'
With ActiveWindow.Selection.ShapeRange(1)
sResponse = InputBox("new name ...", "Rename Shape", .Name)
Select Case sResponse
' blank names not allowed
Case Is = ""
Exit Sub
' no change?
Case Is = .Name
Exit Sub
Case Else
On Error Resume Next
.Name = sResponse
If Err.Number <> 0 Then
MsgBox "Unable to rename this shape"
End If
End Select
End With
With ActivePresentation.Slides(1).Shapes("X")
.Top = 0
.Left = 0
.Height = 271.75
.Width = 453.38
.Line.Visible = msoTrue
.Line.ForeColor.SchemeColor = ppForeground
.Line.BackColor.RGB = RGB(255, 255, 255)
End With
End Sub