VBA Macros

G

Guest

Hello,

I'm having difficulty opening a form I created in powerpoint. I have the
following:

Const Path = "C:\Documents and Settings\SS\My Documents\Office 11\Project 5\"
Dim Templname As String
Sub userform_initialize()
' Initialize the drop down list choices
ComboBox1.Clear
ComboBox2.Clear
ComboBox3.Clear
ComboBox1.AddItem "Green"
ComboBox1.AddItem "Blue"
ComboBox2.AddItem "River"
ComboBox2.AddItem "Fountain"
ComboBox3.AddItem "Seattle"
ComboBox3.AddItem "Hawaii"
End Sub
Private Sub CommandButton1_Click()
Templname = ComboBox1.Text & ".pot"
Application.ActivePresentation.ApplyTemplate Path & Templname
Set VideoSlide = ActivePresentation.Slides(2).Shapes _
.AddMediaObject(FileName:=Path & ComboBox2.Text & ".wmv", _
Left:=380, Top:=150)
With VideoSlide.AnimationSettings.PlaySettings
.PlayOnEntry = msoTrue
.PauseAnimation = msoTrue
.HideWhileNotPlaying = msoFalse
End With

Set PictureSlide = Application.ActivePresentation.Slides(3)
With PictureSlide
.Shapes.AddPicture Path & ComboBox3.Text & ".jpg", True, True, 375,
150, 300, 300
End With
End Sub
Private Sub CommandButton2_Click()
ActivePresentation.SlideShowSettings.Run
Unload UserForm1
End Sub


For some reason when I click the button "createpresentationtravel" on my
toolbar nothing no form appears. Please help. Thank you

John
 
G

Guest

Im no expert on VBA John so take this with a pinch of salt

I think it needs a "userform1.show" added in - could be wrong though
 
S

Steve Rindsberg

Hello,

I'm having difficulty opening a form I created in powerpoint. I have the
following:

Where ... in a module or in the form itself?
And what's supposed to invoke the form?

You mention that it doesn't appear when you click a button on your toolbar but
what code runs when you click the button?

DOES any code run when you click the button? Put a break point in the code and
see if it stops there.
 
G

Guest

Hi Steve,
Where ... in a module or in the form itself?
I created the form by going to tools> VBA editor. There, I created the form
with few buttons and combo boxes.

I also have a macro button ("creatpresentationtravel") that has the
following code (when I go to VBA editor, I see it as a module):

Sub createpresentationtravel()
UserForm1.userform_initialize
UserForm1.Show
End Sub

And what's supposed to invoke the form?

The macro button that I have above: I go to tools>Customize>Commands tab>
Macros> select the button called "createpresentationtravel" and drag it to
the toolbar. But when I click the button nothing seems to happen.

Thanks.

John
 
S

Steve Rindsberg

First off, have a look here; I think it'll help:

Create an ADD-IN with TOOLBARS that run macros
http://www.rdpslides.com/pptfaq/FAQ00031.htm
I created the form by going to tools> VBA editor. There, I created the form
with few buttons and combo boxes.

I also have a macro button ("creatpresentationtravel") that has the
following code (when I go to VBA editor, I see it as a module):

Sub createpresentationtravel()
UserForm1.userform_initialize
UserForm1.Show
End Sub

Sub createpresentationtravel()
' The form itself has an Initialize event
' Best to put the code there and let it run automatically
' UserForm1.userform_initialize
UserForm1.Show
End Sub

In the VBA editor:
Doubleclick the form to open its code view
On the upper right, you'll see a procedure dropdown list box.
From it, choose Initialize or just start a new sub:

Private Sub UserForm_Initialize()

and put your initialization code there.
And what's supposed to invoke the form?

The macro button that I have above: I go to tools>Customize>Commands tab>
the toolbar. But when I click the button nothing seems to happen.

See the page at the link above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top