Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
行输入错误excel VBA_Excel_Vba - Fatal编程技术网

行输入错误excel VBA

行输入错误excel VBA,excel,vba,Excel,Vba,我有一个编译错误:“预期:语句结束”,我只是不明白为什么 守则: Private Sub CommandButton8_Click() Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer myFile = "E:\output.txt" myFile = Application.GetOpenFilename() Open myFile For Input

我有一个编译错误:“预期:语句结束”,我只是不明白为什么 守则:

Private Sub CommandButton8_Click()
Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
myFile = "E:\output.txt"
myFile = Application.GetOpenFilename()
Open myFile For Input As #1
Do Until EOF(1)
       Line Input #1,textline
   text = text & textline
Loop
Close #1

End Sub
错误出现在“行输入#1,文本行”行
有人能帮我吗?

似乎很奇怪,IDE没有在
#1、
文本行之间插入空格。发布的代码是为我编译的,所以在您将代码发布到此处时,该行上可能有一个无法打印的字符消失了。尝试删除该行(可能还有下一行)并重新键入。可能行的开头包含了实际的制表符-这可能解释了奇怪的缩进。您只需要
myFile=“E:\output.txt”
myFile=Application.GetOpenFilename()
,但不能同时使用这两个字符。这个代码是有效的。如果您仍然遇到错误,请说明您遇到了什么错误。@YowE3K,我删除了那一行并重新编写了它,它成功了!非常感谢你!