P
Patrickw
I am creating a document from a program which merges data to a
template, then creates a document which is automatically named by the
program. The program allows me to run macros after the merge. I
don't like the automatic names assigned to the documents, so my macro
calls a SaveAs dialog with a suggested name (strFileName) which is
parsed from words in the document. The SaveAs dialog works
perfectly. I want to delete the automatic version of the file created
by my merge program after saving the new and improved version. I
coded as follows, but get a permission denied message when it gets to
the kill statement.
' Get old File Name and Path
strKillFileName = ActiveDocument.Name
' Create new File Name and Path
' Append Main Document Path to Client Document Directory
strFileName = "M:\Bankruptcy Clients\" + strFileName
' Append File Name to Client Document Path
strFileName = strFileName + "\" + UCase(TXTCreditorName.Value) _
+ " - Letter transmitting Agreed Order to " _
+ strDebtorGramaticalForm + ".doc"
' Save the document
With Dialogs(wdDialogFileSaveAs)
.Name = strFileName
.Show
End With
' Delete old File Name
Kill strKillFileName
What am I doing wrong?
template, then creates a document which is automatically named by the
program. The program allows me to run macros after the merge. I
don't like the automatic names assigned to the documents, so my macro
calls a SaveAs dialog with a suggested name (strFileName) which is
parsed from words in the document. The SaveAs dialog works
perfectly. I want to delete the automatic version of the file created
by my merge program after saving the new and improved version. I
coded as follows, but get a permission denied message when it gets to
the kill statement.
' Get old File Name and Path
strKillFileName = ActiveDocument.Name
' Create new File Name and Path
' Append Main Document Path to Client Document Directory
strFileName = "M:\Bankruptcy Clients\" + strFileName
' Append File Name to Client Document Path
strFileName = strFileName + "\" + UCase(TXTCreditorName.Value) _
+ " - Letter transmitting Agreed Order to " _
+ strDebtorGramaticalForm + ".doc"
' Save the document
With Dialogs(wdDialogFileSaveAs)
.Name = strFileName
.Show
End With
' Delete old File Name
Kill strKillFileName
What am I doing wrong?