用户信息交互
约 295 字小于 1 分钟
2024-07-07
MsgBox
Sub test()
MsgBox "你还好吗?", 4 + 32, "打招呼对话框", "C:/a.chm", 0
End Sub
Sub test1()
Dim i As Integer
i = MsgBox("你还好吗?", 4 + 32, "打招呼对话框", "C:/a.chm", 0)
End Sub
Inputbox
Sub test()
'使用inputbox函数
InputBox "请输入姓名", "登陆框", "此处输入", 100, 100, "C:/a.chm", 0
End Sub
Sub test1()
'使用inputbox方法
Application.InputBox "请输入年龄", "登陆框", "此处输入", 100, 100, "C:/a.chm", 0, 1
End Sub
Sub test2()
'inputbox返回值
Dim i As Integer
i = Application.InputBox("请输入年龄", "登陆框", "此处输入", 100, 100, "C:/a.chm", 0, 1)
End Sub
GetOpenFileName
'打开单个文件并关闭
Sub test()
Dim str As String
Dim wb As Workbook
str = Application.GetOpenFilename("Excel文件,*.xls*", , "请选择")
If str <> "False" Then
Set wb = Workbooks.Open(str)
'#######################
'这里针对打开的WB进行操作
'#######################
wb.Close
End If
End Sub
'打开多选的文件
Sub test1()
Dim arr()
Dim wb As Workbook
On Error Resume Next '这一句上课的时候没加
arr = Application.GetOpenFilename("Excel文件,*.xls*", , "请选择", , True)
If arr(1) <> "False" Then
For i = LBound(arr) To UBound(arr)
Set wb = Workbooks.Open(arr(i))
'#######################
'这里针对打开的WB进行操作
'#######################
wb.Close
Next
End If
End Sub
Application.dialogs
Sub test()
Application.Dialogs(5).Show// [!code focus]
End Sub