Sub FindFileOpen()
On Error Resume Next
MsgBox "请选择要打开的文件", vbOKOnly + vbInformation, "打开文件"
If Not Application.FindFile Then
MsgBox "文件未找到", vbOKOnly + vbInformation, "打开失败"
End If
End Sub
用最简单,最简短的VB命令打开一个文件,请参照!
excel VBA中的打开命令中有密码的字段,例如:
workbooks.open filename:="myworkbook.xls", password:="abcd"
把密码输在“abcd"的位置就行了。
Sub ddd()
Dim path1 As String
path1 = "D:\成绩.xls"
Workbooks.Open path1, , True, , 123456
Workbooks("统计.xls").Worksheets("sheet1").Range("A1") = Workbooks("成绩.xls").Worksheets("sheet1").Range("A1")
End Sub
Set wk = Workbooks.Open(Filename:="成绩.xls", Password:=123456)
ThisWorkbook.Sheets(1).[A1] = wk.Sheets(1).Range("A1").Value