Results 1 to 3 of 3

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  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

Posting Permissions

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