S D
accessd667 at yahoo.com
Fri Apr 23 03:33:50 CDT 2004
hi group, I've got some code (think from internet) that moves a file. Works like a charm. However, I've created a method in a class called .MoveFile and added the 'move-file'-code to it. Now i get the following error: 70, permission denied. So when I call the code in a function it works When I call the code as a method in a class it doesn't work. How come? TIA Sander C O D E I N F O R M '--------------------------------------------------- 'M O V E F I L E '--------------------------------------------------- With cFile .DownloadDir = "D:\Temp Projecten\Access\Switch\Download\" .ImportDir = "D:\Temp Projecten\Access\Switch\44\" txtDownloadDir = .DownloadDir txtImportDir = .ImportDir Call .MoveFile(.DownloadDir, .ImportDir, GetNamePart(strFileName)) End With C O D E I N C L A S S 'Move a file if it exists Function MoveFile(strSourceDir As String, _ strDestinationDir As String, _ strFile As String) As Boolean Dim fso Dim file As String, sfol As String, dfol As String file = strFile ' "test.xls" ' change to match the file name sfol = strSourceDir ' "C:\" ' change to match the source folder path dfol = strDestinationDir ' "E:\" ' change to match the destination folder path Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(sfol & file) Then MsgBox sfol & file & " does not exist!", vbExclamation, "Source File Missing" ElseIf Not fso.FileExists(dfol & file) Then fso.MoveFile (sfol & file), dfol <<== ERROR OCCURS HERE?!! Else MsgBox dfol & file & " already exists!", vbExclamation, "Destination File Exists" End If End Function Public Property Get DownloadDir() As String DownloadDir = m_strDownloadDir End Property Public Property Let ImportDir(ByVal vData As String) m_strImportDir = vData End Property Public Property Get ImportDir() As String ImportDir = m_strImportDir End Property --------------------------------- Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25¢