Pinaceous
Well-known Member
- Joined
- Jun 11, 2014
- Messages
- 1,113
- Office Version
- 365
- Platform
- Windows
Hi All,
I have a code to create a folder onto the desktop but I would like to know how I can insert a file, upon the execution of the code, automatically from the code into the newly created folder?
For example, if I have a file named "Test.pdf" into the folder creation, if I tell the code where the file is on my computer.
Please let me know, if you can help me.
Thank you,
pinaceous
I have a code to create a folder onto the desktop but I would like to know how I can insert a file, upon the execution of the code, automatically from the code into the newly created folder?
VBA Code:
Sub CreateFolders()
Dim sPath As String, sMain As String, sFolder As String
Dim i As Long
sPath = CreateObject("WScript.Shell").SpecialFolders("Desktop")
sMain = sPath & "\" & Sheets(1).Range("A1").Value
If Dir(sMain) = "" Then
MkDir sMain
'Add file Test.pdf from "C:\MISC\Test.pdf"
End If
End Sub
For example, if I have a file named "Test.pdf" into the folder creation, if I tell the code where the file is on my computer.
Please let me know, if you can help me.
Thank you,
pinaceous