Hi,
I wonder if anyone can help me im sure this is easy enough.
I have created some vb code that saves a copy of file but I want the vb and/or the userform to be deleted on the copy, the first page to print and the original to be deleted after the new file has been saved into a sub directly.
Is there anyway of doing this. The code I have so far, saves and prints page one but doesnt delete the vb code or the original I have:
[vba]
Private Sub Generatebutton_Click()
Dim Rec As Integer
Dim ToBeSaved As String
Dim SaveName As String
Dim SaveAsName As String
'Set Drive\Folder to save to
Const SaveRoot = "C:\Documents and Settings\"
'Create name for document
SaveName = Surname & " " & Firstname & " " & No
'Create name for file
SaveAsName = SaveName & ".doc"
'Check for previous instances of the SaveName, if found add incremental suffix
With Application.FileSearch
.NewSearch
.LookIn = ActiveDocument.Path
.SearchSubFolders = False
.FileName = SaveName & "*"
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
MsgBox "This customer has already been refered. Check Duplicate."
ActiveDocument.Close SaveChanges:=False
Else
ActiveDocument.SaveAs FileName:=SaveAsName
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="1", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
MsgBox "File has been saved.Please refer.
End If
End With
End Sub
[/vba]
Any help really appreciated. Thanks