problems with PowerPoint macros not functioning properly

  • Thread starter Thread starter rabinmoser
  • Start date Start date
R

rabinmoser

I have a few macros written for a PowerPoint 2003 presentation. One of these
macros stops functioning when the name of the file is changed or when the
file is placed into another folder. I have not been able to figure out why.
 
It is possible that the code may have certain requirements tied to the file
name or location. Without the code it would be difficult to point out the
reasons for failure.

Regards,
Shyam Pillai

Image Importer Wizard
http://skp.mvps.org/iiw.htm
 
Specifically, I have macros that copy PP sheets, sizes and centers portrait
pictures on the sheet, and another one for landscape pictures. Numbers
required for these operations are input into a USERform, and userform is
hidden with a "Userform1.hide" command so that other macros can use the
numbers from the textboxes in the Userform1. If you close the userform
instead of hiding it, all the info in the text boxes disappear, therefore you
must hide not close the userform. In the original file, I can show and hide
the userform without losing the information. If I change the name of the PP
presentation, or copy it into a folder or another computer, when I hide the
Userform all the information disappears. Suggestion anyone?
 
That sounds strange, but as Shyam said, can you post your code? Odd VBA
problems tend to be much easier to figure out with real code to look at.
 
Below is the code. You will notice code uses values from the userform1.
Userform is closed by the command button click. In the file where code was
originally created, clicking the command button retains all the values
entered into textboxes. When other macros are run they use the values
retained in the userform. When I change the file name, or copy the file into
a folder or into another computer, clicking the command button in the user
form behaves like I closed the userform instead of hide. all the values are
lost, and I cannot run the three macros that depend on values from the
userform.
Sub Enter()
'
' Macro recorded 4/19/2008 by Rabin Moser
'
UserForm1.Show
End Sub


Sub Copy()
'
' Macro recorded 4/6/2008 by Rabin Moser

Dim NumberOfCopies As Integer
Dim I As Integer
On Error GoTo Warning1
I = UserForm1.TextBox1.Value



NumberOfCopies = I

On Error GoTo Warning
ActiveWindow.Selection.Copy

Do Until NumberOfCopies = 1
ActiveWindow.View.Paste
NumberOfCopies = NumberOfCopies - 1
Loop
ActivePresentation.Slides.Range(Array(1)).Select
GoTo LastLine
Warning:
Msg = "You must select a slide to copy"
Title = " Slide not Selected"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
GoTo LastLine
Warning1:
Msg = "You have not entered number for copies"
Title = " Preferences not Selected"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
LastLine:
End Sub


Sub CRP()
'
' Macro recorded 16.02.2008 by Rabin Moser
'
Dim I As Double
Dim J As Double
Dim K As Integer
On Error GoTo Warning3
With ActiveWindow.Selection.ShapeRange
If .Height / .Width > 1 Then GoTo Warning2
End With

On Error GoTo Warning1
K = UserForm1.TextBox2.Value
If K > 25 Then K = 25.4

PictureWidth_cm
= K

I = PictureWidth_cm * 28.34
J = I * 432.88 / 575.88

On Error GoTo Warning
With ActiveWindow.Selection.ShapeRange
.Fill.Transparency = 0#
.Height = J
.Width = I
.IncrementLeft (25.4 - PictureWidth_cm) / 2 * 29
.IncrementTop (25.4 - PictureWidth_cm) / 2 * 27 * 0.75

End With
GoTo LastLine
Warning:
Msg = "You must select a picture to size and Position"
Title = " No Picture Selected"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
GoTo LastLine
Warning1:
Msg = "You have not entered a picture width"
Title = " Preferences not Selected"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
GoTo LastLine
Warning2:
Msg = "This is a portrait picture please choose CP"
Title = " Wrong Picture Type"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
GoTo LastLine
Warning3:
Msg = " Slide is empty or no picture selected"
Title = "No Selection for Sizing and Positioning"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
GoTo LastLine
LastLine:
End Sub


Sub CP()
'
' Macro recorded 16.02.2008 by Rabin Moser
'
Dim I As Double
Dim J As Double
Dim L As Integer
On Error GoTo Warning3
With ActiveWindow.Selection.ShapeRange
If .Width / .Height > 1 Then GoTo Warning2
End With
On Error GoTo Warning1
L = UserForm1.TextBox3.Value / 2.54
If L > 7.5 Then L = 7.5

J = L * 2.54 * 26.5
I = J * 432.88 / 575.88

On Error GoTo Warning
With ActiveWindow.Selection.ShapeRange
.Fill.Transparency = 0#
.Height = J
.Width = I
.IncrementLeft (25.4 - I / 28.34) / 2 * 29
.IncrementTop (19.05 - J / 28.34) / 2 * 27

End With
GoTo LastLine
Warning:
Msg = "You must select a picture to center in slide"
Title = " No Picture Selected"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
GoTo LastLine
Warning1:
Msg = "You have not entered a slide height"
Title = " Preferences not Selected"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
GoTo LastLine
Warning2:
Msg = "This is a landscape picture please choose CRP"
Title = " Wrong Picture Type"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
GoTo LastLine
Warning3:
Msg = " Slide is empty or no picture selected"
Title = "No Selection for Sizing and Positioning"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
GoTo LastLine
LastLine:
End Sub
Sub Transition()
'
' Macro recorded 4/21/2008 by Rabin Moser
'
Dim A As Integer

On Error GoTo Warning1
A = UserForm1.TextBox4.Value

With ActiveWindow.Selection.SlideRange.SlideShowTransition
.Speed = ppTransitionSpeedSlow
If UserForm1.CheckBox1.Value = True Then
.AdvanceOnClick = msoTrue
Else
.AdvanceOnClick = msoFalse
End If
.AdvanceOnTime = msoTrue
.AdvanceTime = A
End With
GoTo LastLine
Warning1:
Msg = "You have not entered time for slide duration"
Title = " Preferences not Selected"
DialogStyle = vbOKOnly
Response = MsgBox(Msg, DialogStyle, Title)
LastLine:
'ActiveWindow.View.DisplaySlideMiniature = msoTrue
End Sub
 
Back
Top