I have the following code that will open a txt file into a new workbook and then copy that workbooks cells into the workbook that i'm running. When i close the new workbook i get the question 'there is a large amount information on the clipboard, do you want to be able to paste it later? "YES", "NO" or "CANCEL".
how can i get VB to answer 'yes' to that question automatically?
or is there another way to close that workbook and after i have pasted the information?
at the moment i have the workbook.close line commented out.
Code
Dim Sourcebook As Workbook
10
Filter = "All Files (*.*), *.*"
DATfile = Application.GetOpenFilename _
(filefilter:=Filter, _
filterindex:=1, _
title:="Select DAT file to import")
If DATfile = False Then
YeahImSure = MsgBox("No File was selected. Press ReTry to try again.", vbRetryCancel, "Please select file")
If YeahImSure = vbCancel Then
Exit Sub
End If
End If
'Prompt which file you selected
msg = "You have selected the following file to be imported: " & DATfile & vbCrLf & vbCrLf
YepDone = MsgBox(msg & "Is this the correct DAT file?", vbYesNo, "Import File check")
If YepDone = vbNo Then
GoTo 10
End If
'Load the DAT file from the selected path..
Workbooks.Open Filename:=DATfile
Cells.Select
Selection.Copy
Set Sourcebook = ActiveWorkbook
'ActiveWindow.Close
Workbooks("Calculate.xls").Activate
Worksheets("Import Sheet").Select
Range("A1").Select
ActiveCell.PasteSpecial
Display More
Thank you
Brian G.