gstylianou
Registered User.
- Local time
- Today, 18:33
- Joined
- Dec 16, 2013
- Messages
- 359
Hello,
I'm trying to create a function so to copy from master folder another subfolder into C:\Program Files (x86) but i have some errors. First of all following is the function
Public Function CopyFolderAndSetPermissions(ByVal sourceFolder As String, ByVal targetFolder As String, ByVal permissionLevel As String)
Dim objFSO As Scripting.FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFolder As Object
objFolder = "C:\Program Files (x86)\NutriSoft" Here is the error 91 Object variable or with block variables not set
permissionLevel = "Users - Full"
targetFolder = "C:\NutriSetup Plus_v2.0\Resources\APP\NutriSoft"
'Check if the folder exists
If objFSO.FolderExists(targetFolder) Then
'Copy the Nutrisoft folder to C:\Program Files (x86)
objFSO.CopyFolder sourceFolder, targetFolder
'Get the newly copied folder
Set objFolder = objFSO.GetFolder(targetFolder)
'Set permissions for the folder
objFolder.SetPermissions "Everyone", permissionLevel
Else
MsgBox "The folder " & targetFolder & " does not exist!"
End If
End Function
I tried to call the function from Form1 using the following code
Private Sub Command0_Click()
Call CopyFolderAndSetPermissions("C:\NutriSetup Plus_v2.0\Resources\APP\NutriSoft", "C:\Program Files (x86)", "admin")
End Sub
Please help..
I'm trying to create a function so to copy from master folder another subfolder into C:\Program Files (x86) but i have some errors. First of all following is the function
Public Function CopyFolderAndSetPermissions(ByVal sourceFolder As String, ByVal targetFolder As String, ByVal permissionLevel As String)
Dim objFSO As Scripting.FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFolder As Object
objFolder = "C:\Program Files (x86)\NutriSoft" Here is the error 91 Object variable or with block variables not set
permissionLevel = "Users - Full"
targetFolder = "C:\NutriSetup Plus_v2.0\Resources\APP\NutriSoft"
'Check if the folder exists
If objFSO.FolderExists(targetFolder) Then
'Copy the Nutrisoft folder to C:\Program Files (x86)
objFSO.CopyFolder sourceFolder, targetFolder
'Get the newly copied folder
Set objFolder = objFSO.GetFolder(targetFolder)
'Set permissions for the folder
objFolder.SetPermissions "Everyone", permissionLevel
Else
MsgBox "The folder " & targetFolder & " does not exist!"
End If
End Function
I tried to call the function from Form1 using the following code
Private Sub Command0_Click()
Call CopyFolderAndSetPermissions("C:\NutriSetup Plus_v2.0\Resources\APP\NutriSoft", "C:\Program Files (x86)", "admin")
End Sub
Please help..
Last edited: