View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
SandyR SandyR is offline
external usenet poster
 
Posts: 9
Default permission denied

I wrote the code shown below to copy certain files to a list of directories.
The list is contained in the spreadsheet to which the code is attached. I
have access to all the files and directories used, but the program is telling
me "permission denied" on the copyfile statement. I am new to VB, so maybe
I have the syntax wrong or something. Any help would be appreciated.

The code:

Sub copyauxfiles()

Dim rnum
Dim destpath As String
Dim source As String
Dim basebook As Workbook
Dim basesheet As Worksheet
Dim rowsub As Integer
Dim nrows As Long
Dim ncol As Integer
Dim arraysub As Integer
Dim fs As Object

Set fs = CreateObject("Scripting.filesystemobject")
source = "k:\budget\master files\form D.xls"
Set basebook = ThisWorkbook
Set basesheet = basebook.Worksheets("PARAMETER LIST")

nrows = basesheet.Range("a1").End(xlDown).Row

For rowsub = 1 To (nrows - 1)
destpath = "J:\budget\" & basesheet.Cells(rowsub, 1).Value & "\blank forms"
fs.copyfile source, destpath, True
Next rowsub
End Sub