|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
给个思路和实例,将所有的成语通过Excel表格录入数组。比如:
Private Sub CommandButton1_Click()
Dim arr
Me.TextBox1.Text = ""
With CreateObject("Excel.application")
.Visible = False
.DisplayAlerts = False
Set wb = .Workbooks.Open(ActivePresentation.Path & "\成语.xlsx")
arr = wb.worksheets("成语").Range("A1").currentregion
Randomize
With Me.TextBox1
.Text = arr(IIf(Int(Rnd * UBound(arr)) + 1 >= UBound(arr), UBound(arr), Int(Rnd * UBound(arr)) + 1), 1)
.ForeColor = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
.BackColor = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
.Font.Name = Array("方正魏碑简体", "方正启体简体", "方正苏新诗柳楷简体", "汉鼎简特粗黑", "楷体", "黑体", "华文中宋", "全新硬笔楷书简")(Int(Rnd * 7))
End With
wb.Close False
Set wb = Nothing
.Quit
End With
End Sub
若满意请赏朵小花。 |
评分
-
2
查看全部评分
-
|