Copyfile Error 52
Contents |
Forums Microsoft Access fs.copyfile receiving error 52 - Bad file name or number Results 1 to 3 of 3 fs.copyfile receiving error 52 - Bad file name or numberThis is copyfile error 5 a discussion on fs.copyfile receiving error 52 - Bad file name or number
Vbscript Copyfile Error Handling
within the Microsoft Access forums, part of the Question Forums category; Greetings, i'm getting a RunTime error 52 when trying
Runtime Error 52 Bad File Name Or Number
to execute a backup of my .mdb file with the following ... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools
Runtime Error 52 Bad Filename Or Number Fix
Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Apr 25th, 2005,03:11 PM #1 kwagner1 Board Regular Join Date Jun 2003 Posts 445 fs.copyfile receiving error 52 - Bad file name or number Greetings, i'm getting a RunTime error 52 when trying to execute a backup of my .mdb file with the following code. Code works fine when i hard code the runtime error 52 fix path into the "COPYFILE" command.... any ideas why it wont work as coded below?? thanks! Sub testbackup() On Error GoTo ErrorHandler Dim strCurrentDB, strCurrentDBNoExt As String Dim strBackupPath As String Dim strDay, strTime, strSaveName As String Dim fs As Object strCurrentDB = Application.CurrentProject.Name ' get ".mdb" name strCurrentDBNoExt = Mid(strCurrentDB, 1, Len(strCurrentDB) - 4) 'Trim off extension strBackupPath = Application.CurrentProject.Path & "\Backups\" 'set the Backup pathname strCurrentDB = Application.CurrentProject.Path & "\" & strCurrentDB strCurrentDB = """" & strCurrentDB & """" ' put the string in double quotes strDay = Format(Date, "yyyymmdd") ' get the day value strTime = Format(Time, "hhmmss") ' get the time value strSaveName = strCurrentDBNoExt & " " & strDay & strTime & ".mdb" strSaveName = """" & strBackupPath & strSaveName & """" ' put the string in double quotes MsgBox strCurrentDB & ", " & strSaveName ' display what copyfile cmd will look like Set fs = CreateObject("Scripting.FileSystemObject") fs.copyfile strCurrentDB, strSaveName ' copy the file (**** WORKS FINE IF I HARD CODE PATH NAME.. WHY???) ErrorHandlerExit: Exit Sub ErrorHandler: MsgBox "Error No: " & Err.Number & "; Description: " & _ Err.Description Resume ErrorHandlerExit End Sub Share Share this post on Digg Del.icio.us
+ Ask a Question Need help? Post your question and get tips & solutions from a community of 418,443 IT Pros & Developers. It's runtime error 52 excel macro quick & easy. FileCopy command - Runtime error 52 Bad File Name visual basic 6.0 setup toolkit runtime error 52 or Number P: 4 TracyWants2Know Access Version: 2002 SP3 OS: MS Windows XP Professional Code from Module: Dim txtFileNameBuES As microsoft access bad filename or number String Dim txtFileNameBuESXP As String Dim txtPathNameBuTo As String txtFileNameBuES = DLookup("[ESPCLoc]", "Variables") txtFileNameBuESXP = DLookup("[DBLoc]", "Variables") txtPathNameBuTo = DLookup("[BackupLoc]", "Variables") cpyst1 = Chr$(34) & txtFileNameBuES & Chr$(34) cpyst2 = Chr$(34) & http://www.mrexcel.com/forum/microsoft-access/138051-fs-copyfile-receiving-error-52-bad-file-name-number.html txtFileNameBuESXP & Chr$(34) cpyst3 = Chr$(34) & txtPathNameBuTo & "\ExpressScore.mdb" & Chr$(34) cpyst4 = Chr$(34) & txtPathNameBuTo & "\ExpressScoreXP.mdb" & Chr$(34) FileCopy cpyst1, cpyst3 FileCopy cpyst2, cpyst4 --- Contents of fields in table: txtFileNameBuES=C:\Program Files\WorkKeys\Working\ExpressScore.mdb txtFileNameBuESXP=C:\Program Files\WorkKeys\Working\ExpressScore.mdb txtPathNameBuTo=C:\WorkKeys\Backup I am trying to make a copy of two files ES and ESXP into the backup folder. Different sites using this have different locations for their files, https://bytes.com/topic/access/answers/823286-filecopy-command-runtime-error-52-bad-file-name-number so I'd prefer not to hardcode the path. I get the error message listed in the Title. Not sure how to use the Immediate indow in Debug to check, or what else to do. I have been searching all day with no luck. Thanks. Jul 21 '08 #1 Post Reply Share this Question 7 Replies Expert 5K+ P: 8,398 ADezii Hello Tracy, try: Expand|Select|Wrap|Line Numbers DimtxtFileNameBuESAsString DimtxtFileNameBuESXPAsString DimtxtPathNameBuToAsString txtFileNameBuES=DLookup("[ESPCLoc]","Variables") txtFileNameBuESXP=DLookup("[DBLoc]","Variables") txtPathNameBuTo=DLookup("[BackupLoc]","Variables") FileCopytxtFileNameBuES,txtPathNameBuTo&"\ExpressScore.mdb" FileCopytxtFileNameBuESXP,txtPathNameBuTo&"\ExpressScoreXP.mdb" Jul 21 '08 #2 reply P: 4 TracyWants2Know YEESSSSS!!! Thank you very much, that worked perfectly!!! Jul 23 '08 #3 reply Expert 5K+ P: 8,398 ADezii YEESSSSS!!! Thank you very much, that worked perfectly!!! You are quite welcome. I guess you can now change you name from TracyWants2Know to TracyNowKnows! (LOL). Jul 23 '08 #4 reply P: 4 TracyWants2Know What if I wanted to copy multiple files into one? FileCopy C:\WorkKeys\Rock.txt+Chester.txt, C:\WorkKeys\AllFiles.txt Jul 31 '08 #5 reply Expert 5K+ P: 8,398 ADezii What if I wanted to copy multiple files into one? FileCopy C:\WorkKeys\Rock.txt+Chester.txt, C:\WorkKeys\AllFiles.txt I'm almost positive that you cannot do that with FileCopy, but all is not lost if the know the File Names a
Posts : 6 Scores: 0 Reward points : 0 Joined: 3/14/2006 Status: offline Filesystem object copyfile method error codes Tuesday, March 14, 2006 5:25 AM (permalink) 0 Hey Everyone, I'm kinda new to scripting but so http://www.visualbasicscript.com/Filesystem-object-copyfile-method-error-codes-m32260.aspx far I"m doing ok. However, I'm trying to write a routine that will backup one of my database servers and then email me, so far I haev most of it working, but I want to be http://community.flexerasoftware.com/archive/index.php?t-77613.html able to write any errors it gets to a logfile. However, i don't know what the error codes for the copyfile method are. Nor can I seem to find them on the net. I want do error 5 something silly like this: fs.CopyFile strSrc1, strDst1, True if err.number <> 0 Then logf.write "Error encountered, the error is...... (Andthen insert what went wrong) Pardon my newness, I'm sure this is a pretty easy thing for some of you gurus :) Thanks in advance!! #1 ebgreen Total Posts : 9274 Scores: 172 Reward points : 0 Joined: 7/12/2005 Status: offline RE: Filesystem object copyfile method error codes Tuesday, March 14, 2006 runtime error 52 5:28 AM (permalink) 0 You typically don't need to know what the error codes are. The Err object includes a .Description property that is usually descriptive enough. I do what you are trying something like this: If Err.Number <> 0 Then logf.write "Error encountered while doing FOO - (" & Err.Number & ") - " & Err.Description End If Stop the Help Vampires:http://slash7.com/2006/12/22/vampires/ VB is NOTVB.Net which is NOTVBA which is NOTVBScript #2 mcgyver74 Total Posts : 6 Scores: 0 Reward points : 0 Joined: 3/14/2006 Status: offline RE: Filesystem object copyfile method error codes Tuesday, March 14, 2006 6:30 AM (permalink) 0 Thanks dude, that's exactly waht I am looking for!!!! #3 mcgyver74 Total Posts : 6 Scores: 0 Reward points : 0 Joined: 3/14/2006 Status: offline RE: Filesystem object copyfile method error codes Wednesday, March 15, 2006 3:28 AM (permalink) 0 That's working great. But I do have one more quick Q. is the err.description valid for programs called with a shell.run command? For example I have the following code strCopyStatus0 = objShell.Run ("xcopy " & strDrive & "\a2000 /s /d /y " & strA2KBkupLoc & "a2000" , 1, TRUE) If strCopyStatus0 <> "0" Then logf.Write "Errors were encountered during the file copy" &
Version : Error 76: Unable to copy file... - ISWI1.52 when using MergeModules NewsArchive08-22-2000, 12:00 AMI just created a project with ISWI 1.5 and Language Pack West installled. The only feature includes the CMDialog ActiveX Merge Module in addition to two other MMs. When building the release I get the following errors any help appreciated Georg ** Error 76: Unable to copy file C:\SYS\NT40\Profiles\glillig\Personal\MySetups\MAHLE2000\Build Label 1\Interm\MergeModules\COMCAT.3207D1B0_80E5_11D2_B95D_006097C4DE24\Redist\MS\System\comcat.dll in to the release location. ** Error 76: Unable to copy file C:\SYS\NT40\Profiles\glillig\Personal\MySetups\MAHLE2000\Build Label 1\Interm\MergeModules\OLEAUT32.8C0C59A0_7DC8_11D2_B95D_006097C4DE24\Redist\MS\System\olepro32.dll in to the release location. ** Error 76: Unable to copy file C:\SYS\NT40\Profiles\glillig\Personal\MySetups\MAHLE2000\Build Label 1\Interm\MergeModules\OLEAUT32.8C0C59A0_7DC8_11D2_B95D_006097C4DE24\Redist\MS\System\stdole2.tlb in to the release location. ** Error 76: Unable to copy file C:\SYS\NT40\Profiles\glillig\Personal\MySetups\MAHLE2000\Build Label 1\Interm\MergeModules\OLEAUT32.8C0C59A0_7DC8_11D2_B95D_006097C4DE24\Redist\MS\System\asycfilt.dll in to the release location. ** Error 76: Unable to copy file C:\SYS\NT40\Profiles\glillig\Personal\MySetups\MAHLE2000\Build Label 1\Interm\MergeModules\OLEAUT32.8C0C59A0_7DC8_11D2_B95D_006097C4DE24\Redist\MS\System\oleaut32.dll in to the release location. ** Error 76: Unable to copy file C:\SYS\NT40\Profiles\glillig\Personal\MySetups\MAHLE2000\Build Label 1\Interm\MergeModules\COMDLG32.576D64B0_7413_11D2_B954_006097C4DE24\Redist\MS\System\comdlg32.ocx in to the release location. NewsArchive08-25-2000, 12:00 AMNow I have the very same error with Merge Modules. This sucks. Tom. Georg Lillig