Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-29-2012, 10:16 AM
dwillyfan dwillyfan is offline Remove first character from text file Windows 7 64bit Remove first character from text file Office 2010 64bit
Novice
Remove first character from text file
 
Join Date: Aug 2012
Posts: 4
dwillyfan is on a distinguished road
Default Remove first character from text file

I have some code written to remove the first character from my text file, but can seem to get it to work. I have a comma at the start of my text file when I extract the data from a word form, but it won't import correctly into my database without manually removing the comma. Can anyone help me modify my coding?

Code:
Function myReplaceFileText(myFilePathInput As String, myFilePathOutput As String, myReplaceString As String, myString As String)
     
    Dim myFileString As String
     
    Open "C:\folder\file.txt" For Input As #1
    myFileString = Input(LOF(1), 1)
    Close #1
     
    myFileString = Replace(myFileString, myReplaceString, myString, Compare:=vbTextCompare)
    
    Open myFilePathOutput For Output As #2
    Print #2, myFileString
    Close
End Function
Sub Test()
     
    Dim myFilePathInput As String
    Dim myFilePathOutput As String
    Dim myReplaceString As String
    Dim myString As String
     
    myFilePathInput = "C:\folder\file.txt"
    myFilePathOutput = "C:\folder\file.txt"
    myReplaceString = ","
    myString = ""
     
    Call myReplaceFileText(myFilePathInput, myFilePathOutput, myReplaceString, myString)
     
End Sub

Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove first character from text file Need help matching text to the Character Map Bobosmite Word 1 07-12-2012 08:12 AM
Remove first character from text file Need help on Macro 03- Find text - if text is blank then remove line simpleonline1234 Word VBA 1 02-25-2011 02:28 AM
Remove first character from text file Weird ÿ character replaces text robinvda Word 3 01-25-2011 03:00 PM
Outlining a text character powrus1 Word 1 01-04-2011 12:50 PM
automatically extract footnotes into new file and apply character format to footnote hrdwa Word 0 02-27-2010 03:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft