I need help. Please explain to me if i can add a load event to my slides (using VBA). Example: When i load slide 3, a macro to be executed.
Is that possible? If yes, how to do that? Thanks.
Do you want this to happen in slideshow view or in normal editing view?
If in slide show view, the simplest thing might be to add your own navigation buttons that trigger a macro like:
Sub NextSlide()
' go to the next slide
ActiveWindow.View.GotoSlide (SlideShowWindows(1).View.GotoSlide(SlideShowWindows(1).View.Slide.SlideIndex))
' and insert whatever code you like here:
End Sub
Related
Is it possible to show a pop-up message (using VBA in Powerpoint) to the presenter which won't be visible to the "audience"?
Edit: Of course, it would be nice if you could tell me "how".
Thanks in advance!
Something like this, perhaps:
Add a userform with a label to contain the text you want to display.
Add this to the vba project:
Sub PopUp()
With UserForm1
.Show (vbModeless)
.Left = 100
End With
End Sub
Add a shape to any slide where you want to display the popup and give it an action setting of Run Macro: PopUp
This assumes that you've accepted the default userform name; change the subroutine to reflect any name changes if you like.
It also assumes that the main monitor is on the left side; if not, you'll need to change the .Left value.
I have PowerPoint with a slide master set so all slides have same characteristics. I want to use VBA to place the SlideIndex number of the corresponding slide on each side.
As of now I have it so when you click a button, the slide index pops up in a message box but I want it to pop up in a text box or something on the slide itself.
Here is the script I am currently using..
Private Sub CommandButton_Click()
MsgBox SlideShowWindows(1).View.Slide.SlideIndex
End Sub
I do not want to use a button. I want to automatically have it on each slide when its ran..Thanks in advance
Add a text box to one slide. While it's selected, type this in the Immediate window to name it something meaningful to you:
ActiveWindow.Selection.ShapeRange(1).Name = "SlideNumber"
Then your button handling code can look like:
With SlideShowWindows(1).View.Slide.SlideIndex.Shapes("SlideNumber")
.TextFrame.TextRange.Text = Cstr(SlideShowWindows(1).View.Slide.SlideIndex)
End with
By the way, you don't need VBA for this.
Go to the slide master view. On the master, add a text box wherever you want the slide index to appear.
While you have the text insertion cursor active, choose: Insert | Slide Number
I'm populating PowerPoint slides with data from an Excel spread sheet. At the moment, I'm accessing the slide using the page number:
Set mySlide = PowerPointApp.ActivePresentation.Slides(1)
Using the Master View option in the UI, you can rename the slide. How can I find the slide using that name?
Thanks,
Carlo.
ActivePresentation.Slides(i).Master.Design.Name
It is the name you see for the theme, in the master view for the slide.
layoutIndex = ActivePresentation.Slides(i).CustomLayout.Index
It is the current layout of the slide in the above theme.
ActivePresentation.Slides(i).Master.Design.Parent.CustomLayouts.Item(layoutIndex).Name
It is the layout name of the currently selected layout of the slide.
it is the VBA, what you can say :-).
Using the Slide.Name property will define the name of the slide and allow it to be called using:
ActivePresentation.Slides("Name")
per the MSDN
So, what I wanted was a way to uniquely identify a PPT slide through VBA. The problem is that I still need to be able to identify that slide if it is copied to another PPT document.
So, what I found I had to do was:
create a text box on each page and hard-code the text to be something like "Slide:Cover" or "Slide:QuarterlyResults", etc.
loop through each slide
find "Slide:" and strip it out to get the page title. That way, if the slide is copied to another PPT document, the name goes with it.
create a Dictionary that uses the Slide.SlideID as the key and the page title as the value.
Then what I do is loop through the slides, get the SlideID, use the Dictionary to get the page title and use a Select statement to map to the proper method to process the slide.
Yeah, I know... it's an icky hack, but it's the only way I could think of doing it.
Thanks for you help,
Carlo.
Pop up charts in VBA Excel
I was very curious with the answer in the above link.
My question is, Can I pop up a graph with click of button(The button is on Sheet1) and when i go bach to
Sheet thr graph is gone
Pertinent to your question as it is worded in the Title (i.e. 'Can i launch userform from a button in a Sheet'), you can implement this functionality in two simple steps:
1). From Excel 'Developer' tab select Insert -> Button. By default, it will create a new Button1 and corresponding Click event handle will be added to the Module1
Sub Button1_Click()
End Sub
2). Provided that you have a User Form named UserForm1, add a single statement in that event handle that will open the UserForm1 on Button click:
Sub Button1_Click()
UserForm1.Show
End Sub
In case you are trying to implement additional functionality, please include your code snippet highlighting the problematic part.
Hope this will help. Best regards,
Let's do it by point and basing on the answer you have posted.
Can I pop up a graph with click of button(The button is on Sheet1)?
Yes, you can. You need to:
Put a Button on Sheet1 and associate to it a macro, let's say popUpChart;
Create and show the chart:
Sub popUpChart()
Dim ch As UserForm1
Set ch = New UserForm1
'ch.CommandButton1_Click()
'a) Uncomment the line above if you want to invoke the button press before to show the chart
'b) If you decide to uncomment, remember to change the sub from "Private" to "Public"
ch.Show
End Sub
when i go bach to Sheet thr graph is gone
I don't understand well what you mean here. Do you mean "I want the graph to be gone when I go back to the sheet" or "I would like the chart to stay here but actually it's gone?
a) In the first case, it's enough to remove the image from the Image control of the form;
b) In the second case, it's enough to remove the Set statement from the button's macro.
This is related to this question
How do I programmatically/automatically change the text formatting for the text of a Visio shape after I am done with the editing?
There I tried to use some code that would be executed when the text of a shape is edited
For some reasons, as described there, in some situations which I could not isolate the code is executed endlessly.
That is probably because the script calls itself in a loop. The code is supposed to be executed every time the text of the shape is edited BUT the code itself changes the color of the text. I guess that would count as a new text change and so on.
I am thinking about using the event called TextChanged. According with the documentation this should execute the code when the user finished the editing
http://msdn.microsoft.com/en-us/library/office/ff768749.aspx
I could not find a example of using such event in VBA and here is where I need your help
thanks in advance
Uni
This is how I tested:
I used CallThis('ThisDocument.warning") to call the procedure below from "TheText" event of that shape (available via the shapesheet)
Sub warning(oShape As Visio.Shape)
MsgBox ("Text edited")
End Sub
This gets executed like three times if I star editing the text of a shape and I press the space key (adding a space to the existing text)
Ok here is how you do it:
Open the Code editor
In the Project explorer select "ThisDocument"
Next in the ObjectWindow select Document
Then in the Method dropdown box select ShapeExitedTextEdit
You will see a skeleton procedure like below
Private Sub Document_ShapeExitedTextEdit(ByVal oShape As IVShape)
End Sub
There is where you add the code that you want to be executed every time when the editing if finished