VBA to Copy a file and Rename it

M.Enders

New member
Local time
Today, 15:37
Joined
Dec 6, 2016
Messages
3
Hello,

I am trying to have access VBA copy a folder and then rename it to a naming convention based on the combo boxes.

The need naming convention should be me.combo131 & "_" & me.combo133 & "_" & me.combo135 & me.combo137

Help me


Dim FSO As New FileSystemObject
Dim FolderPath1 As String
Dim FolderPath2 As String
Dim FolderToPath As String

FolderPath1 = Me.Text139.Value
FolderPath2 = "C:\RASAP\Closeout\" & Me.Combo133 & "\"


If FSO.FileExists(Nz(Me.Text139.Value, "")) Then
FSO.CopyFile Me.Text139, FolderPath2 & "\", True
End If
 
And what problem do you've with that, any errors or ??
 
JHB.

my problem is I simply do not know the code that will allow me to rename the file once it has been copied into the folder.
 
Thank you so much. The code that I ended up using is as follows:

Dim FSO As New FileSystemObject
Dim FolderPath1 As String
Dim FolderPath2 As String

FolderPath1 = Me.Text139.Value
FolderPath2 = "C:\RASAP\Closeout\" & Me.Combo133 & "\" & Me.Combo131 & "_" & Me.Combo133 & "_" & Me.Combo135 & Me.Combo137 & ".pdf"

If FSO.FileExists(Nz(Me.Text139.Value, "")) Then
Name FolderPath1 As FolderPath2
MsgBox "Files Uploaded into RASAP in " & Me.Combo131 & " Folder"
Me.Text139 = ""
End If
 

Users who are viewing this thread

Back
Top Bottom