Hello all
So far I have this code:
It creates a main folder with year (ie: 2021) if it doesn't exist
Then, It creates a subfolder based on a field (ie: DR-21-007) if it doesn't exist
Then, It copies two files with paths input from another two fields. (Storage for path, user defined) to above folder
Now, I also want to rename the file to what it was + & strSerial
I was thinking, in the following line: Call fso.CopyFile(TRevChk, strSFolder & strSerial & "\", no)
Change to: Call fso.CopyFile(TRevChk, strSFolder & strSerial & "\" name Path & filename AS path & newname, no)
Is my thinking wrong for above?
So far I have this code:
Code:
Private Sub btnGenerate_Click()
Const strParent = "M:\429 QMO\Document Reviews\Document Reviews\"
Dim strSerial As String
Dim strSFolder As String
Dim strFolder As String
Dim fso As Object
Dim FDate As String
Dim Path As String
Dim TRevChk As String
TRevChk = Forms!frmConfig!fileTRevChk.Value
Dim TPriAss As String
TPriAss = Forms!frmConfig!fileTPriAss.Value
Path = strParent & Me.fldSerial
FDate = Format(Now, "yyyy")
strSFolder = strParent & FDate & "\"
strFolder = strParent & FDate
strSerial = Me.fldSerial
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
On Error Resume Next
If FolderExists(strFolder) = False Then
fso.CreateFolder strFolder
End If
If fso.FolderExists(strSFolder & strSerial) = False Then
fso.CreateFolder strSFolder & strSerial
Call fso.CopyFile(TRevChk, strSFolder & strSerial & "\", no)
Call fso.CopyFile(TPriAss, strSFolder & strSerial & "\", no)
Else
MsgBox "Folder " & strSerial & " already exists"
MsgBox "Path " & TRevChk & " exists"
Call fso.CopyFile(TRevChk, strSFolder & strSerial & "\", no)
Call fso.CopyFile(TPriAss, strSFolder & strSerial & "\", no)
End If
Me.txtFileDoc.Value = Path
Shell "explorer.exe " & strSFolder & Me.fldSerial, vbNormalFocus
Me.Requery
End Sub
It creates a main folder with year (ie: 2021) if it doesn't exist
Then, It creates a subfolder based on a field (ie: DR-21-007) if it doesn't exist
Then, It copies two files with paths input from another two fields. (Storage for path, user defined) to above folder
Now, I also want to rename the file to what it was + & strSerial
I was thinking, in the following line: Call fso.CopyFile(TRevChk, strSFolder & strSerial & "\", no)
Change to: Call fso.CopyFile(TRevChk, strSFolder & strSerial & "\" name Path & filename AS path & newname, no)
Is my thinking wrong for above?