|
我试了一下,不知是否中意,代码如下:
Private Declare Function MessageBoxTimeout Lib "user32" Alias "MessageBoxTimeoutA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long, ByVal wlange As Long, ByVal dwTimeout As Long) As Long '申明自动关闭对话框
Private Sub CommandButton1_Click()
Set sld = ActivePresentation.SlideMaster
For Each sp In sld.Shapes
If sp.Name = "文本2" Then sp.Delete
Next
生成字母
写入
End Sub
Sub 生成字母()
w = ActivePresentation.PageSetup.SlideWidth / 2 - 10
h = ActivePresentation.PageSetup.SlideHeight / 2 + 15
Randomize
i = Int(Rnd * 11) + 1
zt = Choose(i, "汉仪中楷简", "方正字迹-张颢硬笔楷书", "方正苏新诗柳楷简体", "方正魏碑简体", "华文隶书", "华文楷体", "汉仪南宫体简", "全新硬笔楷书简", "汉鼎简楷体", "楷体_GB2312", "华文行楷", "方正北魏楷书简体", "方正康体简体", "方正黄草简体", "汉仪细行楷简")
zty = Choose(i, "Arial", "Arial Black", "Ebrima", "Franklin Gothic Demi Cond", "Impact", "Microsoft Sans Serif", "Times New Roman", "Arial Narrow", "Franklin Gothic Heavy", "Rockwell Extra Bold", "WideLatin") '"Segoe Print",
zs = Choose(i, vbBrown, vbGreen, vbGray, vbOrange, vbRed, vbPink, vbYellow, vbWhite, VbViolet, Thistle, Fuchsia, MediumPurple)
ds = Choose(i, vbGreen, vbBrown, vbGray, vbOrange, vbRed, vbPink, vbYellow, vbWhite, VbViolet, Thistle, Fuchsia, MediumPurple)
Set sld = ActivePresentation.SlideMaster
Randomize
Set shp = sld.Shapes.AddShape(1, w - 70, h - 60, 150 + 50, 60 + 30)
With shp
.Name = "文本2"
.Fill.ForeColor.RGB = RGB(128, 128, 128)
With .TextFrame.TextRange
.Font.Bold = True
.Font.Size = 100
.Font.NameOther = zty
.Font.Name = zty
'.Font.NameFarEast =zt
.Font.Color.RGB = zs 'RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
End With
End With
End Sub
Sub 写入()
If Val(SlideMaster.Shapes("文本1").TextFrame.TextRange.Text) < 91 Then
SlideMaster.Shapes("文本1").TextFrame.TextRange.Text = IIf(Val(SlideMaster.Shapes("文本1").TextFrame.TextRange.Text) > 65, Val(SlideMaster.Shapes("文本1").TextFrame.TextRange.Text), 65)
SlideMaster.Shapes("文本2").TextFrame.TextRange.Text = Chr(Val(SlideMaster.Shapes("文本1").TextFrame.TextRange.Text))
SlideMaster.Shapes("文本1").TextFrame.TextRange = Val(SlideMaster.Shapes("文本1").TextFrame.TextRange.Text) + 1
Else
MessageBoxTimeout 0, "已经超限,从头开始!", "警告先生", vbOKCancel, 0, 1000
SlideMaster.Shapes("文本1").TextFrame.TextRange.Text = 65
End If
End Sub
|
|