Consulting

Results 1 to 3 of 3

Thread: First to digit remove from text file without open by vba coding

  1. #1
    VBAX Newbie
    Joined
    Oct 2013
    Location
    Rajasthan - India
    Posts
    3
    Location

    Post First to digit remove from text file without open by vba coding

    "i have a text file i have 12 digits string i want to delet first 2 digits withou open the text file , i am also attached a script with this i have coding pleaseTxt file is below like , i want this change without opme text file because files is very huge.""919712121210""919712121211""919712121212""919712121214""I need like this"" 9712121210,Massage""9712121211,Massage""9712121212,Massage""9712121214,Mass age""Below is the coding "
    Sub Test() 
       Dim fn As String, txt As String, myWord As String, Counter As Integer, 
    Filename1 As String    Counter = 4 
          If Cells(Counter, 1).Value  "" Then 
       Set currentWB = ActiveWorkbook 
       Do While fn = Cells(Counter, 1).Value  "" 
       fn = Cells(Counter, 1).Value 
       myWord = Cells(Counter, 12).Value 
       Filename1 = Cells(Counter, 9).Value    
    On Error Resume Next  
    OR    
    On Error GoTo 0
    On Error GoTo ErrO 
       txt = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll 
       Open fn For Output As #1    Print #1, Replace(txt, vbCrLf, myWord & vbCrLf), Close #1 
       Counter = Counter + 1 
       'On Error GoTo ErrH 
           Loop 
       Else    
    MsgBox "Mass row files are not attached", vbExclamation 
       Exit Sub 
       End If
    ErrO:   Select Case Err         
    Case 68, 75, 62:    ' Error 68: "Device not available"    ' Error 75: "Path/File Access Error" 
               MsgBox "There is an error reading drive B."         
    Case 76, 55:        ' Error 76: "Path not found" 
               MsgBox "The specified path is not found." 
     Case 5:   ' Error 5: "Files format not correct" 
     MsgBox "Files are not correct." 
            Case Else:      ' An error other than 68, 75 or 76 has occurred. 
               ' Display the error number and the error text.            
    MsgBox "Error # " & Err & " : " & Error(Err) 
         End Select 
                 End Sub
    Last edited by Aussiebear; 10-18-2013 at 04:55 AM. Reason: Not Visible right format

  2. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Not enough information.

    Please copy 10 lines from the txt file into Notepad and save the Notepad file as Example.txt and attach it to your next post.

    Also, copy the worksheet with the file names to a new workbook, delete all except the top ten rows, (first three rows and 7 data rows,) and attach the new workbook.

    You can attach files by using the "Go Advanced" button below the post editor, then using the "Manage Attachments" button below the Advanced post editor.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Newbie
    Joined
    Oct 2013
    Location
    Rajasthan - India
    Posts
    3
    Location

    Smile

    i have resolved self , i hope i will tuch with you next time thanks for support VBA Team.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •