DWUTKA at marlow.com
DWUTKA at marlow.com
Fri Aug 4 16:15:25 CDT 2006
Ah, your missing the first f=freefile. That sets f to a number that represents a 'file' to the OS. Put it between the 'Dim strtemp As String' and the open statement. Drew -----Original Message----- From: Mark A Matte [mailto:markamatte at hotmail.com] Sent: Friday, August 04, 2006 2:29 PM To: accessd at databaseadvisors.com Subject: Re: [AccessD] Edit Large text file via VBA Dim f As Long Dim strtemp As String Open "C:\temp\y2003d.txt" For Binary Access Read As f strtemp = Space(LOF(f)) Get f, , strtemp Close f strtemp = Replace(strtemp, "\|", "") f = FreeFile Open "C:\temp\y2003ded.txt" For Binary Access Write As f Put f, , strtemp Close f >From: DWUTKA at marlow.com >Reply-To: Access Developers discussion and problem >solving<accessd at databaseadvisors.com> >To: accessd at databaseadvisors.com >Subject: Re: [AccessD] Edit Large text file via VBA >Date: Fri, 4 Aug 2006 14:19:00 -0500 > >Can you post your code? > >Drew > >-----Original Message----- >From: Mark A Matte [mailto:markamatte at hotmail.com] >Sent: Friday, August 04, 2006 1:51 PM >To: accessd at databaseadvisors.com >Subject: Re: [AccessD] Edit Large text file via VBA > >Drew, > >Thanks for the code...I'm getting an error on the OPEN line when I >execute...error="Bad file name or number" > >I even shortened the name to less than 8 characters...no spaces, just >letters. > >Any ideas? > >Thanks, > >Mark A. Matte > > > >From: DWUTKA at marlow.com > >Reply-To: Access Developers discussion and problem > >solving<accessd at databaseadvisors.com> > >To: accessd at databaseadvisors.com > >Subject: Re: [AccessD] Edit Large text file via VBA > >Date: Fri, 4 Aug 2006 13:10:33 -0500 > > > >Dim f as long > >Dim strTemp as string > >F=freefile > >Open "C:\PathToFile\FileName.txt" for binary access read as f > >Strtemp=space(lof(f)) > >Get f,,strtemp > >Close f > >Strtemp=replace(strtemp,"WhateverCharactersYouWantToReplace","") > >F=freefile > >Open "C:\NewFile.txt" for binary access write as f > >Put f,,strtemp > >Close f > > > > > >If you just want to replace the original file, I recommend using the kill > >statement to delete the old file, then change the path of the last 'open' > >statement to rewrite it. If you 'write' a file that is smaller then the > >one > >you are writing over, you'll get the remainder at the end. > > > >Drew > > > >-----Original Message----- > >From: Mark A Matte [mailto:markamatte at hotmail.com] > >Sent: Friday, August 04, 2006 1:02 PM > >To: accessd at databaseadvisors.com > >Subject: [AccessD] Edit Large text file via VBA > > > >Hello All, > > > >I know someone helped me do this a couple of years ago...but I can't find > >it > > > >in my stuff or the archives. > > > >I need to search a large pipe delimited text file and remove a string of > >characters. I'm sure I opened it in vba and did this 'search/edit' > >thing...but not sure where to start. > > > >Also...importing it is not an option due to the one of ther characters I > >need to delete. > > > >any ideas? > > > >Thanks, > > > >Mark A. Matte > > > > > >-- > >AccessD mailing list > >AccessD at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/accessd > >Website: http://www.databaseadvisors.com > >-- > >AccessD mailing list > >AccessD at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/accessd > >Website: http://www.databaseadvisors.com > > >-- >AccessD mailing list >AccessD at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/accessd >Website: http://www.databaseadvisors.com >-- >AccessD mailing list >AccessD at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/accessd >Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com