gstylianou
Registered User.
- Local time
- Today, 16:49
- Joined
- Dec 16, 2013
- Messages
- 359
Hi, i'm trying to copy from desktop to C:\Program Files (x86) using vba but i cannot because of the limited permission. I found the following code in a forum. Any idea?
Public Sub CopyMasterFolder()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
FromPath = "C:\Users\User\Desktop\NutriSetup\Resources\NutriSoft"
ToPath = "C:\Program Files (x86)"
If Right(FromPath, 1) = "\" Then
FromPath = Left(FromPath, Len(FromPath) - 1)
End If
If Right(ToPath, 1) = "\" Then
ToPath = Left(ToPath, Len(ToPath) - 1)
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
FSO.CopyFolder Source:=FromPath, Destination:=ToPath
Me.cmd2.FontBold = False
Me.cmd2.Caption = "Files copied from " & FromPath & " in " & ToPath
' MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath
End Sub
Public Sub CopyMasterFolder()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
FromPath = "C:\Users\User\Desktop\NutriSetup\Resources\NutriSoft"
ToPath = "C:\Program Files (x86)"
If Right(FromPath, 1) = "\" Then
FromPath = Left(FromPath, Len(FromPath) - 1)
End If
If Right(ToPath, 1) = "\" Then
ToPath = Left(ToPath, Len(ToPath) - 1)
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
FSO.CopyFolder Source:=FromPath, Destination:=ToPath
Me.cmd2.FontBold = False
Me.cmd2.Caption = "Files copied from " & FromPath & " in " & ToPath
' MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath
End Sub