Filecopy Error 52
Contents |
+ Ask a Question Need help? Post your question and get tips & solutions from a community of 418,550 IT
Runtime Error 52 Bad File Name Or Number
Pros & Developers. It's quick & easy. FileCopy command - Runtime error runtime error 52 bad filename or number fix 52 Bad File Name or Number P: 4 TracyWants2Know Access Version: 2002 SP3 OS: MS Windows XP Professional runtime error 52 fix Code from Module: Dim txtFileNameBuES As String Dim txtFileNameBuESXP As String Dim txtPathNameBuTo As String txtFileNameBuES = DLookup("[ESPCLoc]", "Variables") txtFileNameBuESXP = DLookup("[DBLoc]", "Variables") txtPathNameBuTo = DLookup("[BackupLoc]", "Variables") cpyst1 = Chr$(34)
Runtime Error 52 Excel Macro
& txtFileNameBuES & Chr$(34) cpyst2 = Chr$(34) & 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
Visual Basic 6.0 Setup Toolkit Runtime Error 52
backup folder. Different sites using this have different locations for their files, 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,409 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,409 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,409 ADezii What if I wanted to copy multiple files into one? FileCopy C:\WorkKeys\Rock.txt+C
File I/O and Registry > Why can't I get FileCopy to work? Thread Tools Display Modes #1 07-22-2010, 05:02 AM IndraG microsoft access bad filename or number Junior Contributor Join Date: Feb 2006 Posts: 204 Why can't I get
Bad Filename Or Number Access Import
FileCopy to work? I am trying FileCopy in VB6, it should be a very simple thing, I want to copy error 52 driver one file in C:\ to D:\. This is my simple code: Private Sub Form_Load() FileCopy("C:\Test.txt", "D:\Test.txt") End Sub Should be a piece of cake right? But it keeps coming up with this https://bytes.com/topic/access/answers/823286-filecopy-command-runtime-error-52-bad-file-name-number error: "Compile error: Expected: =" I tried: FileCopy "C:\Test.txt" "D:\Test.txt" The error became: "Compile error: Expected: end of statement" Sorry to sound so dumb, but, can anybody help to get this work? Thank you so much... IndraG View Public Profile Find all posts by IndraG #2 07-22-2010, 05:21 AM Flyguy Lost Soul Super Moderator* Guru * Join Date: May 2001 Location: Vorlon http://www.xtremevbtalk.com/file-i-o-and-registry/317153-cant-filecopy.html Posts: 19,124 Just place the cursor on FileCopy and press F1 to see the correct syntax Flyguy View Public Profile Find all posts by Flyguy #3 07-22-2010, 10:51 AM Gruff Bald Mountain Survivor Retired Moderator* Expert * Join Date: Aug 2003 Location: Oregon, USA Posts: 6,440 To Expand on Flyguy's answer. Your second attempt would work if you separated the source argument from the target argument with a comma. --- RE: Parenthisis in VB6. Functions return values and must be wrapped in parenthisis Example1: Function Calculate: Total = Calculate(Num1, Num2, Num3) Sub Routines do not return values and must not use parenthisis. Example2: Sub Routine ShowPicture ShowPicture Picture1, PicSize, PicRotation The exception to this rule is that VB6 allows you to wrap a Sub Routine in parenthisis if you use the 'Call' keyword before the Sub Routine name. Most do not like this option because they feel it clutters up code. Example2.5: Sub Routine ShowPicture Call ShowPicture(Picture1, PicSize, PicRotation) --- Keep in mind that VB6 is really old technology that drags sections of earlier versions of VB along with it. Some commands are 'Statement
Way | Trading Add-ins For Excel | Convert Excel Into Calculating Web Pages Excel Web Pages | Produce Clean Efficient VBA Code Every http://www.ozgrid.com/forum/showthread.php?t=146683 Time | Build Automated Trading Models In Excel | Excel Web http://www.vbforums.com/showthread.php?176089-Filecopy-to-accept-wildcards Pages | Excel Video Training Forum New Posts FAQ Calendar Forum Actions Mark Forums Read Quick Links Today's Posts What's New? Advanced Search Forum HELP FORUMS Excel General FileCopy with spaces in file name Excel Training / Excel Dashboards Reports If this is your first visit, be sure error 52 to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. If you don't like Google AdSense in the posts, register or log in above. Click here to view the runtime error 52 relaunched Ozgrid newsletter. Results 1 to 7 of 7 Thread: FileCopy with spaces in file name Thread Tools Show Printable Version Search Thread Advanced Search October 1st, 2010 #1 cytop View Profile View Forum Posts . Join Date 1st September 2010 Posts 10,911 FileCopy with spaces in file name I can't believe this one has me stumped, but... Trying to use FileCopy where the destination file has spaces in it, for example: "J:\Location\Department\Data Quality\3. Issues Tracking\Supporting Documentation\Emails\000203\abc.abc" I've tried all sorts of gubbins with Chr$(34), multiple quote marks and just about every possible permutation thereof but always get an Error 52 (Bad file name or number). This is related to the destination filename with the spaces. I can FileCopy Source, Source & "XXX" (for example) no problem I can also copy the file using Windows Explorer, using a DOS box and a Copy command with quotes around the filename, but no way is it going to happen in code. I would appreciate someone else's perspective of this before I start barking... Excel Video Tutorials / Excel Dashboards Re
this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 7 of 7 Thread: Filecopy to accept wildcards? Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Jun 4th, 2002,06:58 AM #1 dermodyr View Profile View Forum Posts Thread Starter Lively Member Join Date Jul 2001 Posts 95 Filecopy to accept wildcards? Hi All, I am trying to get my filecopy command to accept wildcards but it doesnt seem to be possible e.g. It gives me a run-time error "52". Bad File name or number FileCopy "l:\020603??.log", "c:\mydocu~1\proxy\AllLogs.log" Is there any way that I can do this through VB? Thanks Ray Reply With Quote Jun 4th, 2002,07:06 AM #2 phinds View Profile View Forum Posts PowerPoster Join Date Aug 2001 Location new jersey Posts 2,904 you can use your wild-card file name as a pattern for a file list box and write your own loop to copy all the files in the list. Reply With Quote Jun 4th, 2002,07:09 AM #3 peet View Profile View Forum Posts -= B u g S l a y e r =- Join Date Aug 2000 Posts 9,629 VB Code: Private Sub Command1_Click() Dim sFile As String sFile = Dir("l:\020603??.log") Do While sFile <> "" FileCopy sFile, "c:\mydocu~1\proxy\" & Mid(sFile, InStrRev(sFile, "\") + 1) sFile = Dir LoopEnd Sub have not tested this -= a peet post =- Reply With Quote Jun 4th, 2002,07:24 AM #4 peet View Profile View Forum Posts -= B u g S l a y e r =- Join Date Aug 2000 Posts 9,629 oioioi.. sorry about that VB Code: Private Sub Command1_Click() Dim sFile As String Dim sPath As String Dim sDestPath As String sPath = "C:\LOG\" sDestPath = "C:\LogBak\" sFile = Dir(sPath