I'm developing a PowerPoint2007 Add-on using VSTO(Visual Studio Tools for Office)
I'm trying to add a wavfile to slide and modify animation setting of the wave file.
The problem is occurred when I modify AnimationSettings.PlaySettings's member attributes of the wave file shape then some of animation effect in the slide deleted.
This behavior is very weird.
I don't understand why some of animation effect has been deleted after I modify the PlaySettings's member attributes.
code :
Shape s = Globals.ThisAddIn.Application.ActivePresentation.Slides[slideIndex].Shapes.AddMediaObject(wavFilePath, 0f, 0f);
s.Left = DEFAULT_LEFT_POS;
// If the below code run, some of animation effect are deleted.
s.AnimationSettings.Animate = Microsoft.Office.Core.MsoTriState.msoTrue;
s.AnimationSettings.AdvanceMode = PpAdvanceMode.ppAdvanceOnTime;
s.AnimationSettings.AnimationOrder = 0;
s.AnimationSettings.PlaySettings.PauseAnimation = Microsoft.Office.Core.MsoTriState.msoFalse;
s.AnimationSettings.PlaySettings.PlayOnEntry = Microsoft.Office.Core.MsoTriState.msoTrue;
Can anyone help me?
According to my experiences using AnimationSettings delete all 'exit effects' of other shapes. What you could possibly try is to explore the following PowerPoint objects/references:
`(slide).TimeLine.MainSequence`
which allows to change the animation order (you could add sound shape and than move it up before any exit effect start).
Check also if (Shape).SoundEffect object is not a good substitution for your needs.
I also change tag of your question into powerpoint-vba as it has a reference to that area too.
Related
i'am currently trying to add a small function to PowerPoint using VBA, my goal is to create a gadget that works kind of like Photoshop graphics layer.
My plan is to add a layer name Tag on each shape that is drawn by user, so later I can parse through every item by loop and preform lock/unlock, show/hide shapes based on it's tag value, such as:
Sub add_shape_with_layer_tag()
Set islide = ActivePresentation.Slides(1)
Set ishape = islide.Shapes.AddShape(msoShapeRectangle, 5, 5, 80, 60)
ishape.Tags.Add "Layer", "1"
End Sub
Sub show_hide_layer_one_shapes()
Dim active_slide As Slide
Set active_slide = ActiveWindow.View.Slide
For Each ishape In active_slide.Shapes
If ishape.Tags("Layer") = "1" Then
ishape.Visible = Not (ishape.Visible)
End If
Next ishape
End Sub
However, I couldn't found a way to achieve this, so I would like to ask whether there's a method that provides following functions?
override add shape function so I can sneak tag value in to shape every time user drawn a shape
catch add shape event (if this thing did exist) so i can add tag to the last added item
a way to set a default tag value to shape, just like setting default shape color/line width
or is there any better options that is also viable?
thanks.
20200728
To John, thanks for the advice, I did found some interesting event that might be helpful for some of my other projects, however I couldn't found events that able to trigger after custom function while shape is added.
To Steve, my plan is to add a modeless userform with list UI that manage layers, the shape tag and shape fill texture/color will be determined based on what list item that currently selected.
As to saving settings, I'll use VBComponents.CodeModule to dump existing settings in userforms to a VBA module and store as text, so in theory I should able to make this function self contained in one file.
Not totally an answer, sorry SO, but comments don't allow enough scope for this. So ...
To Steve, my plan is to add a modeless userform with list UI that manage layers, the shape tag and shape fill texture/color will be determined based on what list item that currently selected.
Ah, so you're creating your own "pseudo-layers". That wasn't clear. Thanks for the add'l info. As it happens, I have a selection manager add-in that works very similarly to what you're proposing.
To John, thanks for the advice, I did found some interesting event that might be helpful for some of my other projects, however I couldn't found events that able to trigger after custom function while shape is added.
The SelectionChange event should get you there. When it fires, you'll need to check first to see if the current selection is a shape or something else. If a shape, check to see if its .Index = current slide's .Shapes.Count and also to see if you've already tagged it. If no tag AND if it's the correct index, it'll be a newly added shape. If you're tagging ALL shapes, you may only need to check to see if the .Tag(name) is blank.
As to saving settings, I'll use VBComponents.CodeModule to dump existing settings in userforms to a VBA module and store as text, so in theory I should able to make this function self contained in one file.
Why not save any needed slide or presentation level info as further slide- or presentation-level tags? PPT can absorb quite a lot of info as tags w/o getting cranky.
I am trying to implement a 'Flag' w/ a menustrip.
I have an image list w/ a red flag and a black flag.
When I click the menu item, i want to toggle the image.
The problem I have is that once I change the image, it wants to do SizeToFit which makes the Icon roughly the height of text. I dont want that. I want the Image to be its actual size.
I have tried putting the statements in different orders, nothing i have tried seems to work.
Currently, I have the button set to the black flag at design time.
This code shows me trying to change to a Red flag.
tsbFlagPatient.Image = ilFlags.Images(1)
tsbFlagPatient.ImageScaling = ToolStripItemImageScaling.None
tsbFlagPatient.DisplayStyle = ToolStripItemDisplayStyle.Image
[If there is some better way to approach toggling the image, im open to that. That seems like a separate question. ]
I was unable to make ImageScrolling work.
Since I dont need text here, I used BackGround Image and set
BackgroundImageLayout = Stretch
This allows the images to be the right size.
You can turn AutoSize = false and then manually set Height, Width to fine tune your menu's size.
I did reconsider the ImageList and changed the images to being stored in the project Resources. This is the code to toggle the image
Public Sub SetFlagImage(flagSet As Boolean)
If flagSet = False Then
btnFlag.BackgroundImage = My.Resources.appbar_flag_wavy_black
btnFlag.BackgroundImage.Tag = "black"
Else
btnFlag.BackgroundImage = My.Resources.appbar_flag_wavy_red
btnFlag.BackgroundImage.Tag = "red"
End If
End Sub
This had no effect on the question posed here. In general, probably better than having an image list because all forms can access it.
Working with VB.NET in Visual Studio 2015. During debugging, is there any way to view the value of a variable inside a 'With' block by hovering with the mouse?
For example, in the code below, if I hover over lSection or lSection.MomentZ or lSection.MomentY or others, VS displays information about the object and/or the value of the variable (as expected).
However, if I hover over any object starting with a period (.SectionIndex or .SectionLocation or .Mx or .M_y or .Vx), VS will NOT show any tooltip at all.
NOTE: I am aware that I can add the the variable to a Watch window. I know there are other ways to get the value of the variable, but I want to be able to just hover with the mouse because it is literally (yes, literally) 900 million times faster.
I could only find one other question similar to this one, but the answer does not explain whether or not there is ANY possible way to enable this feature (VS setting, registry hack, 3rd party add-on, i don't care how)
How to view VB.NET object properties in the debugger within a "With object" block?
With mCSIDetails
.ClearCSIResults()
' Section Index and Location
.SectionIndex = lSection.ID
.SectionLocation = Round(lSection.FracLen * mMember.Length, 3)
' Section forces and moments
.P = lSection.AxialForce
If liAxis = MemberOrientation.Strong Then
.Mx = lSection.MomentZ
.M_y = lSection.MomentY
.Vx = lSection.ShearForce_CSI_12
.Vy = lSection.ShearForceZ_CSI_12
ElseIf liAxis = MemberOrientation.Weak Then
.Mx = lSection.MomentY
.M_y = lSection.MomentZ
.Vx = lSection.ShearForceZ_CSI_12
.Vy = lSection.ShearForce_CSI_12
End If
End With
I posted the same question on the Visual Studio forum and the moderator was able to replicate the issue.
Apparently this is just the new (terrible) way the debugger works. So if you want to be able to mouse-hover and get a tooltip with the object/variable value, then don't use WITH blocks...
I am using WindowsForms and I am trying to put a Textbox into my main menu and add an Image. However I cannot get the image to appear. What am I missing here.
txtRequestEdit.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
txtRequestEdit.Image = Properties.Resources.Wrench16 'This is a valid image.
txtRequestEdit is a System.Windows.Forms.ToolStripTextBox
EDIT- Here is an image of the menu. The item at the bottom of this menu is the txtRequestEdit control.
Strangely the no matter how you apply the image, it won't show on ToolStripTextBox. I think this is a bug because I found nothing about this behavior in the documents or on the web.
I will try doing this with a hack like owner-drawing the item or something else and will put the wrong answer here so the next person with this issue avoids this wrong path.
This is wrong:
Apparently the Image property "supports the .NET Framework infrastructure and is not intended to be used directly from your code.", so if (as you say) everything's OK and you've checked the image itself to be valid, using ImageList and ImageIndex may solve the problem (assuming the item lies inside a MenuStrip named menuStrip1:
txtRequestEdit.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
menuStrip1.ImageList = New ImageList()
menuStrip1.ImageList.Images.Add(Properties.Resources.Wrench16)
txtRequestEdit.ImageIndex = 0
PowerPoint 2010 introduces so called Smart Guides as described here. You can choose to enable or disable this feature in the Grid and Guides settings dialog with the check box "Display smart guides when shapes are aligned".
I'd like to query the setting by code and have looked through the object model for a corresponding property but didn't find any. So have I overlooked it or is it not exposed?
I think you would need to query the registry
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\PowerPoint\Options\ShowSmartGuides
1 = on 0 =Off
We can Show and Hide custom Guides, I am using this in my application.
PowerPoint.Slide _pptSlide = null;
int SlideIndex = PowerPoint.Application.ActiveWindow.Selection.SlideRange.SlideIndex;
_pptSlide = PowerPoint.Application.ActivePresentation.Slides[SlideIndex];
_pptSlide.Application.DisplayGuides = Microsoft.Office.Core.MsoTriState.msoFalse;