use a macro to close a file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro set in 1 workbook that opens a different workbook, copies
information to past into the first workbook then closes the second workbook.
My problem is how do I set the close command to close the second file
without the system message about data on the clipboard - save yes or no?
See code below.
Thank you in advance Dan

Sub Load_Group()
'
GroupNum = Application.InputBox(prompt:=" ENTER A GROUP NUMBER",
Type:=1)
Dim GrpNum As String
GrpNum = GroupNum & ".xls"

ChDir "C:\DATA FILES"
Workbooks.Open Filename:= _
"C:\DATA FILES\Print Out #" & (GrpNum)
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Windows("Invoice_AND_Total_Sheet.xls").Activate
Range("AH3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Windows("Print Out #" & (GrpNum)).Activate
ActiveWorkbook.Close
Range("A1").Select
Calculate
End Sub
 
Add this after the paste to clearout the clipboard

application.CutCopyMode=false


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Try placing the following before the point that the prompt is generated:

Application.DisplayAlerts = False

Be sure to reset it at the end of your code as follows:

Application.DisplayAlerts = True

Hope this helps.
 
thank you much.
knew it was somthing simple but could not get my brain back on the right
track.

Dan
 
The you for your answer.
The previous posting from Bob P. is a bit more in line as all I needed to do
was to clear the clipboard.
This way I do not need to remember to reset the Message Alert system.

Dan
 
Back
Top