【问题标题】:Right vba coding while delaing with userform buttons处理用户窗体按钮时正确的 vba 编码
【发布时间】:2016-11-28 13:07:42
【问题描述】:

下面的代码在不同的模块中运行良好,但如果用于用户窗体按钮则不能。它不会在即时窗口中打印文件的内容。我请求更正或指导。 谢谢你

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

【问题讨论】:

    标签: vba text-files userform private-class


    【解决方案1】:

    天哪!我是多么愚蠢。我刚刚删除了 Chr(34)(引号),它起作用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-23
      • 1970-01-01
      • 2017-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-11
      相关资源
      最近更新 更多