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