VBA to Copy a file and Rename it (2 Viewers)

M.Enders

New member
Local time
Today, 00:20
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
 

JHB

Have been here a while
Local time
Today, 08:20
Joined
Jun 17, 2012
Messages
7,732
And what problem do you've with that, any errors or ??
 

M.Enders

New member
Local time
Today, 00:20
Joined
Dec 6, 2016
Messages
3
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.
 

M.Enders

New member
Local time
Today, 00:20
Joined
Dec 6, 2016
Messages
3
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

Top Bottom