VBA to VB.Net code Help

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


0
Utf
4/22/2010 10:45:01 AM
powerpoint 2011 articles. 0 followers. Follow

9 Replies
2670 Views

Similar Articles

[PageSpeed] 12

In article <653FEC6A-F658-4378-AB93-81C3AFBBB9B6@microsoft.com>, Naro25 wrote:
> 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.

I don't use VB.net of any vintage so can't give you exact instructions, but it 
might help if you posted your code to open PPT etc.  Presumably it's getting an 
object reference to the PowerPoint app and presentation, and most likely the 
code below needs to be modified to work with that object reference; right now, 
it's written to run within PowerPoint.

> 
> 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


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

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


0
Steve
4/22/2010 3:31:17 PM
Many thanks for your input Steve. I have the same question posted on VBforums 
but can't get a response there either. IYO can you recommend the best port of 
call forum for this? 

Thanks.

"Steve Rindsberg" wrote:

> In article <653FEC6A-F658-4378-AB93-81C3AFBBB9B6@microsoft.com>, Naro25 wrote:
> > 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.
> 
> I don't use VB.net of any vintage so can't give you exact instructions, but it 
> might help if you posted your code to open PPT etc.  Presumably it's getting an 
> object reference to the PowerPoint app and presentation, and most likely the 
> code below needs to be modified to work with that object reference; right now, 
> it's written to run within PowerPoint.
> 
> > 
> > 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
> 
> 
> ==============================
> PPT Frequently Asked Questions
> http://www.pptfaq.com/
> 
> PPTools add-ins for PowerPoint
> http://www.pptools.com/
> 
> 
> .
> 
0
Utf
4/24/2010 4:35:01 PM
In article <1AFE12B6-D5F2-4644-8A0D-45269A71638F@microsoft.com>, Naro25 wrote:
> Many thanks for your input Steve. I have the same question posted on VBforums 
> but can't get a response there either. IYO can you recommend the best port of 
> call forum for this? 

This might be as good a place as any, but again, unless we can see how you're 
opening PPT and the presentation and so on, we can't help.  The exact error message 
might be a good thing to post also.

> 
> Thanks.
> 
> "Steve Rindsberg" wrote:
> 
> > In article <653FEC6A-F658-4378-AB93-81C3AFBBB9B6@microsoft.com>, Naro25 wrote:
> > > 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.
> > 
> > I don't use VB.net of any vintage so can't give you exact instructions, but it 
> > might help if you posted your code to open PPT etc.  Presumably it's getting an 
> > object reference to the PowerPoint app and presentation, and most likely the 
> > code below needs to be modified to work with that object reference; right now, 
> > it's written to run within PowerPoint.
> > 
> > > 
> > > 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
> > 
> > 
> > ==============================
> > PPT Frequently Asked Questions
> > http://www.pptfaq.com/
> > 
> > PPTools add-ins for PowerPoint
> > http://www.pptools.com/
> > 
> > 
> > .
> >


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

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


0
Steve
4/24/2010 8:12:27 PM
Hi Steve, sorry I didn't post the open ppt segment as I didnt have an issue 
with it, but here it is below. Im starting to figure some things out like 
adding a image/shapes. e.g.

oPres.Slides(1).Select()
        oShape = 
oPres.Slides(1).Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 100, 100, 100, 100)
        With oShape
            .Fill.Transparency = 1.0#
            .Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
            .Height = 141.75
            .Width = 141.75
        End With

 I could resolve this post if someone could simply give me an example of 
adding an entry/exit effect to an object. That's really all I'm stuck on now. 

Imports Office = Microsoft.Office.Core
Imports PowerPoint = Microsoft.Office.Interop.PowerPoint


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click


        Const sPic = "X.jpg"
        Dim oApp As PowerPoint.Application
        Dim oPres As PowerPoint.Presentation
        Dim oSlide As PowerPoint.Slide
        Dim oShape As PowerPoint.Shape

        'Start Powerpoint and make its window visible but minimized.
        oApp = New PowerPoint.Application()
        oApp.Visible = True
        oApp.WindowState = PowerPoint.PpWindowState.ppWindowMaximized

        'Create a new presentation.
        oPres = 
oApp.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue)
        oPres.SaveAs("c:\mypres.ppt")

        'Build Slide #1:
        'Add text to the slide, change the font and insert/position a 
        'picture on the first slide.
        oSlide = oPres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank)
0
Utf
4/24/2010 9:24:01 PM
Sorry, to be a bit more specific, this is exactly what I'm trying to 
replicate in Vb.Net:

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

0
Utf
4/25/2010 10:27:01 AM
Maybe the coffee hasn't taken hold yet or maybe I'm an idiot.  Maybe 
both, but I'm having real trouble following this because the code you've 
quoted is scattered across two or three different posts.  Would you do 
us a favor and quote the whole thing in one chunk ... what you've got so 
far ... and indicate exactly where errors occur and what the error 
messages are?  Thanks.

0
Steve
4/25/2010 4:44:40 PM
Sorry Steve, it was a bit all over the place. In summary, this is what I've 
got so far:

Imports Office = Microsoft.Office.Core
Imports PowerPoint = Microsoft.Office.Interop.PowerPoint


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click


        Const sPic = "C:\X.jpg"
        Dim oApp As PowerPoint.Application
        Dim oPres As PowerPoint.Presentation
        Dim oSlide As PowerPoint.Slide
        Dim oShape As PowerPoint.Shape

        'Start Powerpoint and make its window visible but minimized.
        oApp = New PowerPoint.Application()
        oApp.Visible = True
        oApp.WindowState = PowerPoint.PpWindowState.ppWindowMaximized

        'Create a new presentation based on the specified template.
        oPres = 
oApp.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue)
        oPres.SaveAs("c:\mypres.ppt")

        'Build Slide #1:
        'Add text to the slide, change the font and insert/position a 
        'picture on the first slide.
        oSlide = oPres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank)

        oSlide.Shapes.AddPicture(sPic, False, True, 150, 150, 500, 350)
        oSlide = Nothing

        oPres.Slides(1).Select()
        oShape = 
oPres.Slides(1).Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 100, 100, 100, 100)
        With oShape
            .Fill.Transparency = 1.0#
            .Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
            .Height = 141.75
            .Width = 141.75
        End With

Ive got all this working fine now. As I mentioned, I'm just struggling with 
the following code brought over from VBA to add animation effects to the 
above object, with the transparent rectangle being the trigger:

With ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Add(1)
            interEffect = .AddEffect(oShape, msoAnimEffectFly, _
            trigger:=msoAnimTriggerOnShapeClick)
            interEffect.shape = sPic

            With interEffect
                .EffectParameters.Direction = msoAnimDirectionLeft
                .Timing.Duration = 0.5
            End With
        End With


        With ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Add(1)
            interEffect = .AddEffect(oShape, msoAnimEffectFly, _
            trigger:=msoAnimTriggerOnShapeClick)
            interEffect.shape = sPic


            With interEffect
                .EffectParameters.Direction = msoAnimDirectionLeft
                .Timing.Duration = 0.5
                .Exit = msoTrue
            End With
        End With


The errors are as follows:
ActivePresentation not declared
intereffect not declared
msoAnimEffectFly not declared
msoAnimTriggerOnShapeClick not declared
etc
etc

Thanks so much for taking the time to help.
Regards,
Naro25
0
Utf
4/25/2010 5:39:01 PM
Thanks!  See below ...

In article <A6A820EC-9501-473B-9DEF-32E189B12B4B@microsoft.com>, Naro25 wrote:
> Sorry Steve, it was a bit all over the place. In summary, this is what I've 
> got so far:
> 
> Imports Office = Microsoft.Office.Core
> Imports PowerPoint = Microsoft.Office.Interop.PowerPoint
> 
> Public Class Form1
> 
>     Private Sub Button1_Click(ByVal sender As System.Object, _
>         ByVal e As System.EventArgs) Handles Button1.Click
> 
>         Const sPic = "C:\X.jpg"
>         Dim oApp As PowerPoint.Application
>         Dim oPres As PowerPoint.Presentation
>         Dim oSlide As PowerPoint.Slide
>         Dim oShape As PowerPoint.Shape
> 
>         'Start Powerpoint and make its window visible but minimized.
>         oApp = New PowerPoint.Application()
>         oApp.Visible = True
>         oApp.WindowState = PowerPoint.PpWindowState.ppWindowMaximized
> 
>         'Create a new presentation based on the specified template.
>         oPres = 
> oApp.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue)
>         oPres.SaveAs("c:\mypres.ppt")
> 
>         'Build Slide #1:
>         'Add text to the slide, change the font and insert/position a 
>         'picture on the first slide.
>         oSlide = oPres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank)
> 
>         oSlide.Shapes.AddPicture(sPic, False, True, 150, 150, 500, 350)
>         oSlide = Nothing
> 
>         oPres.Slides(1).Select()
>         oShape = 
> oPres.Slides(1).Shapes.AddShape
(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 100, 100, 100, 100)
>         With oShape
>             .Fill.Transparency = 1.0#
>             .Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
>             .Height = 141.75
>             .Width = 141.75
>         End With
> 
> Ive got all this working fine now. As I mentioned, I'm just struggling with 
> the following code brought over from VBA to add animation effects to the 
> above object, with the transparent rectangle being the trigger:
> 
> With ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Add(1)
>             interEffect = .AddEffect(oShape, msoAnimEffectFly, _
>             trigger:=msoAnimTriggerOnShapeClick)
>             interEffect.shape = sPic
> 
>             With interEffect
>                 .EffectParameters.Direction = msoAnimDirectionLeft
>                 .Timing.Duration = 0.5
>             End With
>         End With
> 
>         With ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Add(1)
>             interEffect = .AddEffect(oShape, msoAnimEffectFly, _
>             trigger:=msoAnimTriggerOnShapeClick)
>             interEffect.shape = sPic
> 
>             With interEffect
>                 .EffectParameters.Direction = msoAnimDirectionLeft
>                 .Timing.Duration = 0.5
>                 .Exit = msoTrue
>             End With
>         End With
> 



> The errors are as follows:
> ActivePresentation not declared

Change it to oApp.ActivePresentation 
That should work, I think.

> intereffect not declared

Declare it. <g>  Should be a VBA long which'd be a .Net Integer, I think.

> msoAnimEffectFly not declared
> msoAnimTriggerOnShapeClick not declared

I *think* once you make the oApp.ActivePresentation change above, most of the rest 
should fall into line.  At least any of the rest that would compile under VBA.

sPic will need to be declared (as a PowerPoint shape, same as oShape above.

Hope that gets things nudged a bit further along.

> etc
> etc
> 
> Thanks so much for taking the time to help.
> Regards,
> Naro25


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

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


0
Steve
4/25/2010 8:34:33 PM
Hi Steve, thanks that certainly got things nudged along a bit!! I've 
eliminated all errors now but getting caught up on this line:

interEffect = .AddEffect(oShape, PowerPoint.MsoAnimEffect.msoAnimEffectFly, 
PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnShapeClick)

It produces a warning: COMException was unhandled. Full code now is as 
follows:

Imports Office = Microsoft.Office.Core
Imports PowerPoint = Microsoft.Office.Interop.PowerPoint


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click

        Dim oApp As PowerPoint.Application
        Dim oPres As PowerPoint.Presentation
        Dim oSlide As PowerPoint.Slide
        Dim oShape As PowerPoint.Shape
        Dim interEffect As PowerPoint.Effect  (<g> didn't seem to work)
        Dim sPic As PowerPoint.Shape

        'Start Powerpoint and make its window visible but minimized.
        oApp = New PowerPoint.Application()
        oApp.Visible = True
        oApp.WindowState = PowerPoint.PpWindowState.ppWindowMaximized

        'Create a new presentation based on the specified template.
        oPres = 
oApp.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue)
        oPres.SaveAs("c:\mypres.ppt")

        'Build Slide #1:
        'Add text to the slide, change the font and insert/position a 
        'picture on the first slide.
        oSlide = oPres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank)


        oPres.Slides(1).Select()
        oShape = 
oPres.Slides(1).Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 100, 100, 100, 100)
        With oShape
            .Fill.Transparency = 1.0#
            .Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
            .Height = 141.75
            .Width = 141.75
        End With

        sPic = oSlide.Shapes.AddPicture("C:\X.jpg", 
Microsoft.Office.Core.MsoTriState.msoCTrue, 
Microsoft.Office.Core.MsoTriState.msoCTrue, 0, 0, 400, 400)
        oSlide = Nothing

        With 
oApp.ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Add(1)
            interEffect = .AddEffect(oShape, 
PowerPoint.MsoAnimEffect.msoAnimEffectFly, 
PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnShapeClick)
            interEffect.Shape = sPic

            With interEffect
                .EffectParameters.Direction = 
PowerPoint.MsoAnimDirection.msoAnimDirectionLeft
                .Timing.Duration = 0.5
            End With
        End With

    End Sub
End Class



0
Utf
4/25/2010 10:02:01 PM
Reply:

Similar Artilces:

Payout reason codes
Can someone point me to where in the database the payout reason codes are stored? thanks, Store Ops Manager, Database, Reason Codes, Type = Payout "Jason" wrote: > Can someone point me to where in the database the payout reason codes are > stored? > > thanks, Thanks. What I meant (and asked poorly) was if I wanted to design a custom report to show that info where would I need to look? Thanks, "Wendy_I" wrote: > Store Ops Manager, Database, Reason Codes, Type = Payout > > > > "Jason" wrote: > > > Can someo...

Help with macro/and or formula?
Perhaps this is a silly question, but i just can't figure out how t format this worksheet. The problem is that a lot of the cells hav numbers in them with negative signs in the back instead of in the fron (ie. 23-) and i was wondering if anyone knew of a macro/formula i coul use to quickly fix this problem for all the cells. I would b extremely grateful. Thanks -- brefed1 ----------------------------------------------------------------------- brefed15's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3557 View this thread: http://www.excelforum.com/showthre...

VBA code to say Yes or No if any VBA code is present in ActiveWork
Using XL 2003 & 97 Would like hit Ctrl+Shift+V and have an answer either yes or no as to the presence of Any VBA code in the Active Workbook. I do know that about the VBA editor/Explorer or to press the Run Macro button and get a list from various sources . I would like to stay at the keyboard and process a series of macros including one to let me know if I even need to evoke the VBA explorer. TIA Dennis There is no bootstrap macro to tell you whether you have macros or not. If there were there would be no limit to virus writers. --- HTH, David McRitchie, Microsoft MVP - Excel ...

How to Stop Worksheet_Change event from running during code execution
I'm sorry If I've asked this before but I can't find an answer to it. I have the following 2 events in a worksheet module.... Private Sub Worksheet_Change(ByVal Target As Excel.Range) Private Sub Worksheet_SelectionChange(ByVal Target As Range) I run some codes, either in UserForms or general procedures that make changes to this worksheet. Q. Is there a way to by-pass those two events somehow? As an example I have a uf that comes up if a cell is selected in that sheet. So I need those worksheet_Change events to work at that point. But then, the uf does some stuff like inputing ...

Print, Merged Cells, and VBA
Hello I'm looking for a code that will help me with a print job for a worksheet. There are a lot of merged cells and a lot of "IF"s to be used in the VBA for range selection. Thanks in advance, Sarr ...

help
hello, i am modifying the diskperf sample in the wdk so that i can communicate with it from user land. the diskperf sample is WDM. at the end of DriverEntry, i do: RtlInitUnicodeString( &ntUnicodeString, NT_DEVICE_NAME ); status = IoCreateDevice(DriverObject, 0, &ntUnicodeString, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &deviceObject ); where NT_DEVICE_NAME is defined as : #define NT_DEVICE_NAME L"\\Device\\DiskPerfTest" then i set up the symbolic link. then, in the IRP_MJ_DEVICE_CONTROL handler, i do a check for some IOCTRL code...

Some macro help with shelling out to other program
We are using VNC in house to do remote control between workstations. As there are over 25 of them, I would like to set up a little macro in Excel (2003) that when run, displays a list of user names along with a box prompting for which # on the list you want to connect to. Here's what I have so far: ---- Sub RunVNC() Shell ("c:\program files\hyena\vncviewer.exe sv-ws6") End Sub ---- I would like to see something like: 1. Payroll 2. Receivables 3. Accountant 4. Reception Please enter the number to connect to: Typing 1 and pressing ENTER would run the Shell command abov...

Use VBA to update Access table or Query from Excel
Can I use VBA to update Access table or Query from Excel? Thanks in advance Hi Leungkong, > Can I use VBA to update Access table or Query from Excel? Of course, using ADO or DAO. See: http://www.erlandsendata.no/english/index.php?d=envbadacexportado Regards, Jan Karel Pieterse Excel MVP http://www.jkp-ads.com Hi Jan, Thanks. I think ADO is what I want. But I am not only want to export from excel to access. I want to edit some data in access table. For example, Access has a table "ProductList" I want to use Excel to call the product by "Pro...

Invisible Pictures
Never had a prob before, but since yesterday, when I try to put a picture into MS Publisher (2003) it's invisible. It's there, because the placeholders adapt to the new shape and size - but no picture is actually visible. I've tried it with images I've used previously just to make sure it wasn't anything to do with the actual image I was trying to put in, but no joy. Can't find anything in Help or Troubleshooting to address this problem. Much appreciate any ideas as I need to do this for our shop publicity. The third FAQ here Q: Why can I not see images/shapes...

Help with custom entity scenario
We've come across a bit of CRM customisation which I would appreciate any advice you can give. Basically what we are trying to achieve is to be able to log the interest in applications our products could be used in against lead, opportunity and account. The application interest doesn't need to be directly tied to products but we do need the ability to record multiple applications against each. An example of some of the applications is as follows: Anatomy Bacteriology Biochemistry Biological Vaccines Biophysics Blood bank Botany ...

VBA and Scheduled task in Outlook
Hi, how can I: a) pull the query from somewhere and send it by e-mail automatically. E.g. I want to take a temperature table from http://www.wunderground.com/history/airport/EHAM/2009/7/10/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA where 2009/7/10 is the date of yesterday put it into an e-mail and send it automatically each day at 8 o'clock? b) if this is not possible, how can I send an e-mail with the attachment c:\Documents\query20090710.xls each day at 8 o'clock? my boss wants this automatized, I know how to write the VBA code for Excel, but don'...

Is it possible to pass Certification Exams without proper training? Yes now its possible, this site will help you to download all guides and latest exam material for CISCO, MICROSOFT, ORACLE, COMPTIA,
Is it possible to pass Certification Exams without proper training? Yes now its possible, this site will help you to download all guides and latest exam material for CISCO, MICROSOFT, ORACLE, COMPTIA, LINUX. I received many e-mail from visitor about this site and to feel happy because this one can help you pass your certification exams very easily. Visit http://www.FreeExamKing.com ...

How get rid of reveal codes?
How get rid of reveal codes? the symbols are all over my document!! How do I get rid of them?? Try:- ALT + F9 If my comments have helped please hit Yes. Thanks. "Christa" wrote: > How get rid of reveal codes? the symbols are all over my document!! How do > I get rid of them?? Ctrl+* or Ctrl+Shift+8. See http://word.mvps.org/FAQs/Formatting/NonPrintChars.htm -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Christa" <Christa@discussions.microsoft.com> wrote in mes...

vba select field
Hi, having a button on a form, is it possible to select only some fields (all from the same table) of the current record instead of all fields? I've tried this code: RunCommand acCmdSelectRecord RunCommand acCmdCopy Forse dipende dei dati nel record. but it selects ALL fields in the form. Thank you. Remigio hi, On 10.04.2010 18:01, remigio wrote: > having a button on a form, is it possible to select only some fields > (all from the same table) of the current record instead of all fields? > I've tried this code: > > RunCommand acCmdSelectRecord &...

Location of Right Click Start Logo Items
Hi, I have changed the openning location for Windows Explorer at the default location under accessaries and is all good load to new location, however when I use the right click start logo shortcuts "Explore, Open all users, and Explore all users" its not starting at he new location. I want to change the right click start logo shortcuts starting locations but when I right click the shortcuts instead of getting a list so I can go to properties it actually runs the shortcut. I would like to know where to find the actual shortcuts so I can change the starting locatio...

VLOOKUP in VBA
On the worksheet I can insert in a cell =VLOOKUP(C5, Hobokee.xls!AcsLow, 2) and it works perfectly, looks up the value in column 2 of the range named AcsLow in the same workbook. But elswhere I want in a macro to lookup the same table and assign the result to a variable BalAmt. BalAmt = VLOOKUP(AccNum, Hobokee.xls!AcsLow, 2) does not work. It gives a function not defined error on Hobokee. If instead of Hobokee I put Workbooks("Hobokee"), it gives function not defined error for VLOOKUP which it changes to VLookup. I have been overVLOOKUP in the Help file and see nothing wrong. W...

Excel VBA/Macro programming for beginners
Hi all, I know a bit VB 6.0 programming. Will it help me to write exce vba/macro(same thing?).can anybody help me by providing some fre websites where i can have informations/codes for VBA/macro. Please tell me how could i make a *command Button * in a cell in th excel sheet -- sdebu_200 ----------------------------------------------------------------------- sdebu_2000's Profile: http://www.officehelp.in/member.php?userid=430 View this thread: http://www.officehelp.in/showthread.php?t=118812 Posted from - http://www.officehelp.i Try David McRitchie's "getting started with mac...

Turn pc speaker on/off with vba code
Is this possible? Thanks I found something here on how to do it withVBScript. You can probably modify it to work in VBA http://www.pcreview.co.uk/forums/thread-1468591.php -- HTH, Barb Reinhardt "David" wrote: > Is this possible? > Thanks Thanks Barb I'll have a go (I need to improve my web searching skills) "Barb Reinhardt" wrote: > I found something here on how to do it withVBScript. You can probably modify > it to work in VBA > > http://www.pcreview.co.uk/forums/thread-1468591.php > -- > HTH, > ...

I need help with a table formula/mass editting
I have a spreadsheet (.csv) with 1600 products/rows and several columns. One of the columns that has the product descriptions also contains 1600 rows. In each row under that 'description' column is a formula/code to input a chart/table with product details to our web site in a chart form. I have many new products that I need to place on the web site with this layout. I need to know how to optimize that particular column to add specific details to the chart formula for the 1600 products. For instance, I need the chart to be the same on each product but with different ...

Loading a Form from VBA
Hi all, I'd like a module to open and load a form in my Access 2003 database... How can I do this? Use the OpenForm method. Look in the Help file for details. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Mike" <michael.leon.schwartz@gmail.com> wrote in message news:1184770076.109526.207900@o11g2000prd.googlegroups.com... > Hi all, I'd like a module to open and load a form in my Access 2003 > database... How can I do this? > On Jul 18, 10:58 am, "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com&g...

dual Y axis help
I've read over some of these threads. However, I cannot seem to find something that can help me out. Here's what I'm looking to do: I need a 2 Y-Axis bar chart. The left Y-Axis=revenue, the right Y-axis=% of revenue. The X-axis is the country im referring to. What I need to see visually is Revenue being shown, and within the Revenue bar 3 smaller bars representing 3 different Operating expenses(% of revenue format). Is this possible? Am I clear? I just need a bar chart within a bar chart with 2 y-axis. Thanks. Hi, See Jon Peltier's page for links to cluster/stacked ...

Excel and VBA
I am very interested in learning more about using VBA in office, especially Excel. Can you post some resources (online, books, etc) that can be used to help learn about using Visual Basic in office. Thanks! Here's a good place to start: http://www.contextures.com/xlbooks.html Does that help? *********** Regards, Ron XL2002, WinXP "Bob Sinclair" wrote: > I am very interested in learning more about using VBA in office, especially > Excel. Can you post some resources (online, books, etc) that can be used to > help learn about using Visual Basic in office. >...

VBA Customization
Is there a way to get the name of the current company through VBA in Great Plains 8.0? Thanks for all your help. open GreatPlains. Add the current window, it will add the Toolbar then add fields choose the company name on the top left after the user id. >-----Original Message----- >Is there a way to get the name of the current company through VBA in Great >Plains 8.0? > >Thanks for all your help. > > > >. > Thanks. I tried, but I couldn't add company name to the field list. It opens up the login screen instead. Any thoughts? Thanks again. "ger...

Run VBA without show
I want excel to run the VBA code without showing me what it is doing. Which code should i use for that? Sub RunWithoutShow() Application.ScreenUpdating = False 'Paste the vba code here 'end of code 'Change screenupdating property to true Application.ScreenUpdating = True End Sub I hope this helps... Selva V Pasupathy For more on Excel, VBA, & other Resources Please visit: http://socko.wordpress.com You may also (inserting into quote from code example bellow from Socko) Use Application.Visible property to hide the application entirely Sub RunWithoutShow() Appli...

Problems porting application from VS6 to VS.NET
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---559023410-851401618-1090937522=:25951 Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hello. I am experiencing problems with my application when I try to=20 compile it with Visual C++ .NET. It consists of a main program which loads an MFC extension DLL with its=20 own dialog box and some ActiveX controls. The program runs without errors when compiled with VC++ 6.0. There appeared to...