The works I知 doing now are following on from this:
https://www.accessforums.net/showthr...3&goto=newpost
I知 creating a system to manage risk assessments for locations. So, I now have the code to add to a template document. What I now want to do is Copy a template. Paste it in the right location with a new name (using variables from record source.) I have the majority of this complete in one form or another and I知 sure I will be able to tie it all together.
One-part I知 struggling with is defining the name when the file is pasted.
I could paste the file and use VBA to rename, I was wondering if it痴 possible to define the name as you paste?
This is some test code I知 using which does copy and paste a file:
Code:
Private Sub Command93_Click()
Dim FSO
Dim sFile As String
Dim sSFolder As String
Dim sDFolder As String
'This is Your File Name which you want to Copy
sFile = "RAM_Template.docx"
'Change to match the source folder path
sSFolder = "\\*****SERVER\general\****** Documents\!Managment\VBA_Templates_do_not_modify\"
'Change to match the destination folder path
sDFolder = "\\*******SERVER\general\RAMS\*****_RAMS\"
'Create Object
Set FSO = CreateObject("Scripting.FileSystemObject")
'Checking If File Is Located in the Source Folder
If Not FSO.FileExists(sSFolder & sFile) Then
MsgBox "Specified File Not Found", vbInformation, "Not Found"
'Copying If the Same File is Not Located in the Destination Folder
ElseIf Not FSO.FileExists(sDFolder & sFile) Then
FSO.CopyFile (sSFolder & sFile), sDFolder, True
MsgBox "Specified File Copied Successfully", vbInformation, "Done!"
Else
MsgBox "Specified File Already Exists In The Destination Folder", vbExclamation, "File Already Exists"
End If
End Sub
The more I think about it the more im convinced that paste and rename is the only option.