0
我正在尋找代碼來提示現有txt文件(file1)的OpenFile框,然後創建一個新文件並提示SaveAs框爲新txt文件(file2)。稍後將file1的內容保存在file2中。打開txt文件,創建新的txt文件,將舊文本保存到新文件中
到目前爲止我已經得到了第一部分工作正常。我知道第二部分是錯誤的,但我不知道該怎麼做。
我的代碼到目前爲止;
infilename$ = Application.GetOpenFilename("Neutral Files (*.txt),*.txt", , "Open
Neutral File", "OPEN", False)
If infilename$ = "False" Then
msg = MsgBox("No input file selected. Press OK to retry or cancel to quit",vbOKCancel)
If msg = vbOK Then
Do While msg <> vbCancel 'loop until user presses cancel
infilename$ = Application.GetOpenFilename("Neutral Files (*.r01),*.r01", , "Open Neutral File", "OPEN", False)
If infilename$ = "False" Then
msg = MsgBox("No input file selected. Press OK to retry or cancel to quit", vbOKCancel)
End If
Loop
ElseIf msg = vbCancel Then Exit Sub
End If
End If
outfilename$.SaveAs =:"FileName"infilename.txt",False"
If outfilename$ = "False" Then
msg = MsgBox("No output file selected. Press OK to retry or cancel to quit", vbOKCancel)
If msg = vbOK Then
Do While msg <> vbCancel 'loop until user presses cancel
outfilename$ = Application.SaveAsFilename("Neutral Files (*.r01),*.r01", , "Save As Output", "SAVE", False)
If outfilename$ = "False" Then
msg = MsgBox("No output file selected. Press OK to retry or cancel to quit", vbOKCancel)
End If
Loop
ElseIf msg = vbCancel Then Exit Sub
End If
End If
相信我,我已經試過了。我不斷變得愚蠢的'暴露預期'的錯誤,我不知道爲什麼!它當然應該與打開的文件命令具有相同的格式嗎? –
哪一行會引發「預期表達式」錯誤? –
您建議的那個 –