下面的代码在不同的模块中运行良好,但如果用于用户表单按钮则不能。它不会在即时窗口中打印文件的内容。我请求更正或指导。谢谢你
Private Sub UploadBut_Click()
Dim TextFile As Integer
Dim FilePath As String
Dim FileContent As String
Dim P As String
'BrowseFile.Value 是我的用户窗体中的一个文本框,它捕获文件的路径
If BrowseFile.Value = "" Then
MsgBox "Please Select File", , "Upload File"
Else
On Error Resume Next
P = Chr(34) & BrowseFile.Value & Chr(34)
TextFile = FreeFile
FilePath = P
FileContent = Input(LOF(TextFile), TextFile)
Debug.Print FileContent
Close TextFile
End If
End Sub