我正在寻找提示现有 txt 文件 (file1) 的 OpenFile 框的代码,然后创建一个新文件并提示 SaveAs 框输入新的 txt 文件 (file2)。稍后将 file1 的内容保存在 file2 中。
到目前为止,我已经完成了第一部分的工作。我知道第二部分是错误的,但我不知道该怎么做。
到目前为止我的代码;
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