How do I Declare a Variable/Constant?

C

Coogrr

I am writing a set of macros to use in PowerPoint. One of the macros
asks the user to input a prefix. the code is shown below:


Sub Prefix()


ActiveWindow.View.GotoSlide
Index:=ActivePresentation.Slides.Add(Index:=2,
Layout:=ppLayoutText).SlideIndex
ActiveWindow.Selection.SlideRange.Layout = ppLayoutBlank
Dim Message, Title, Default, MyValue
Message = "Enter Frame Number Prefix" ' Set prompt.
Title = "Frame Number Prefix" ' Set title.
Default = "0000" ' Set default.
' Display message, title, and default value.
MyPrefix = InputBox(Message, Title, Default)


End Sub


I want to use MyPrefix in another macro that asks the user to enter a
Framenumber as shown below:


Sub FrameNumber()


ActiveWindow.View.GotoSlide
Index:=ActivePresentation.Slides.Add(Index:=2,
Layout:=ppLayoutText).SlideIndex
ActiveWindow.Selection.SlideRange.Layout = ppLayoutBlank
Dim Message, Title, Default, MyValue


Message = "Enter Frame Number" ' Set prompt.
Title = "Create Frame Number" ' Set title.
Default = "ABC 0000" ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)


ActiveWindow.Selection.SlideRange.Shapes.AddLabel(msoTextOrientationHorizon­tal,

293.75, 66.625, 14.5, 18).Select
ActiveWindow.Selection.ShapeRange.TextFrame.WordWrap = msoFalse
With ActiveWindow.Selection.TextRange.ParagraphFormat
.LineRuleWithin = msoTrue
.SpaceWithin = 1
.LineRuleBefore = msoTrue
.SpaceBefore = 0.5
.LineRuleAfter = msoTrue
.SpaceAfter = 0
End With
With ActiveWindow.Selection.ShapeRange
.Fill.ForeColor.RGB = RGB(237, 246, 247)
.Fill.Visible = msoTrue
.Fill.Solid
End With
With ActiveWindow.Selection.ShapeRange
.Line.ForeColor.RGB = RGB(255, 255, 102)
.Line.Visible = msoTrue
End With
ActiveWindow.Selection.ShapeRange.IncrementLeft -135#
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Font.Size =
12


ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,

Length:=0).Select
MyText = "Frame # "


TotalText = MyText + MyPrefix + MyValue
With ActiveWindow.Selection.TextRange
.Text = TotalText
With .Font
.Name = "Arial"
.Size = 12
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppForeground
End With
End With


End Sub


How do I get MyPrefix to be defined as a public constant (or variable)
so once MyPrefix is entered it will be picked up and used by
Framenumber each time framenumber is run?


Thanks,


Dennis
 
C

Coogrr

Problem solved. Added the following to the project level:

Public MyPrefix As String

Dennis
 

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