cmdOK click command and Options

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 2 problems

1. I have created a cmdOK click button but am having problems with the code
that I have to put in so that when that button is clicked the userform closes.

2. I have option buttons on the userform. when I click on OptionButton1
the code works. When I click on OptionButton2 the code does not work
 
Sophie - please take this the way its meant as advice!!!

"I have some code you cant see and it doesnt work, so whats wrong?" is what
your asking!

maybe post the code so we can see it will help.

_____________________________
John Wilson
Microsoft Certified Office Specialist
 
I have 2 problems

1. I have created a cmdOK click button but am having problems with the code
that I have to put in so that when that button is clicked the userform closes.

Double click the button to open the editor on the button's click event.

Add this:

Me.Hide
Unload [name of your form]
2. I have option buttons on the userform. when I click on OptionButton1
the code works. When I click on OptionButton2 the code does not work

I defer to John's wise advice here.
 
Hi John here is the code you requested:

Any assistance would be great

Private Sub cmdOK_Click()

If OptionButton1 = True Then
ActiveWindow.ViewType = ppViewSlideMaster
ActivePresentation.SlideMaster.Shapes("Rectangle 145").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select

ActivePresentation.SlideMaster.Shapes.AddPicture(FileName:="\\TACTICSMEL-1\DATA\Projects\Transurban\06
2630 Corporate template\Highly Confidential.jpg", LinkToFile:=msoFalse,
SaveWithDocument:=msoTrue, Left:=234, Top:=252, Width:=253, Height:=37).Select
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.69, msoFalse, msoScaleFromBottomRight
.ScaleHeight 0.69, msoFalse, msoScaleFromBottomRight
End With
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.72, msoFalse, msoScaleFromBottomRight
.ScaleHeight 0.72, msoFalse, msoScaleFromBottomRight
End With
With ActiveWindow.Selection.ShapeRange
.IncrementLeft -177.38
.IncrementTop 225.38
End With

End If

If OptionButton2 = True Then
ActiveWindow.ViewType = ppViewSlideMaster
ActivePresentation.SlideMaster.Shapes("Rectangle 145").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select

ActivePresentation.SlideMaster.Shapes.AddPicture(FileName:="\\TACTICSMEL-1\DATA\Projects\Transurban\06
2630 Corporate template\Commercial in Confidence.jpg", LinkToFile:=msoFalse,
SaveWithDocument:=msoTrue, Left:=234, Top:=252, Width:=253, Height:=37).Select
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.69, msoFalse, msoScaleFromBottomRight
.ScaleHeight 0.69, msoFalse, msoScaleFromBottomRight
End With
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.72, msoFalse, msoScaleFromBottomRight
.ScaleHeight 0.72, msoFalse, msoScaleFromBottomRight
End With
With ActiveWindow.Selection.ShapeRange
.IncrementLeft -177.38
.IncrementTop 225.38
End With

End If

If OptionButton3 = True Then
ActiveWindow.ViewType = ppViewSlideMaster
ActivePresentation.SlideMaster.Shapes("Rectangle 145").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select

ActivePresentation.SlideMaster.Shapes.AddPicture(FileName:="\\TACTICSMEL-1\DATA\Projects\Transurban\06
2630 Corporate template\Company Confidential.jpg", LinkToFile:=msoFalse,
SaveWithDocument:=msoTrue, Left:=234, Top:=252, Width:=253, Height:=37).Select
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.69, msoFalse, msoScaleFromBottomRight
.ScaleHeight 0.69, msoFalse, msoScaleFromBottomRight
End With
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.72, msoFalse, msoScaleFromBottomRight
.ScaleHeight 0.72, msoFalse, msoScaleFromBottomRight
End With
With ActiveWindow.Selection.ShapeRange
.IncrementLeft -177.38
.IncrementTop 225.38
End With

End If

If OptionButton4 = True Then
ActiveWindow.ViewType = ppViewSlideMaster
ActivePresentation.SlideMaster.Shapes("Rectangle 145").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select

ActivePresentation.SlideMaster.Shapes.AddPicture(FileName:="\\TACTICSMEL-1\DATA\Projects\Transurban\06
2630 Corporate template\Public.jpg", LinkToFile:=msoFalse,
SaveWithDocument:=msoTrue, Left:=234, Top:=252, Width:=253, Height:=37).Select
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.69, msoFalse, msoScaleFromBottomRight
.ScaleHeight 0.69, msoFalse, msoScaleFromBottomRight
End With
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.72, msoFalse, msoScaleFromBottomRight
.ScaleHeight 0.72, msoFalse, msoScaleFromBottomRight
End With
With ActiveWindow.Selection.ShapeRange
.IncrementLeft -177.38
.IncrementTop 225.38
End With
ActiveWindow.ViewType = ppViewNormal
End If

Me.Hide
Unload Classification

End Sub
 
Hi John here is the code you requested:

Other than the file name of the jpg, it seems that the code for Option1 and Option2 is
the same. Have you verified that the JPG is there and named exactly as your code
calls for?

By the way, the macro recorder grabs all kinds of unnecessary trash when you record
this kind of thing.

Try this instead:

If OptionButton1 = True Then
ActivePresentation.SlideMaster.Shapes.AddPicture _
FileName:="\\TACTICSMEL-1\DATA\Projects\Transurban\06 2630 Corporate
template\Highly confidential.jpg", _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=234, _
Top:=252, _
Width:=253, _
Height:=37)

' adjust the left/top/width/height numbers to give you the size/position
' you want

End If
 

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

Back
Top