Consulting

Results 1 to 4 of 4

Thread: Special Characters

  1. #1
    VBAX Regular mikke3141's Avatar
    Joined
    Jun 2007
    Location
    Klaukkala
    Posts
    53
    Location

    Special Characters

    Hello,

    I'm trying to load the attached text file to excel, but the special character (c in the word Baco) creates a line break. What to do?


    Sub loadit()Dim i As Integer
    Dim pos As Integer
    Dim ffile As String
    Dim ffile2 As String
    
    
    se = "C:\Users\" & Environ("USERNAME") & "\Desktop"
    ffile = se & "\source.csv" 'your source file
    ffile2 = se & "\ready.xls" 'your destination file
    Dim vstring As String
    Dim a As Variant
    Dim b As Integer
    Open ffile For Input As #1
    Open ffile2 For Output As #2
    Do While Not (EOF(1))
    Line Input #1, vstring
    If Not (vstring = "") Then
    vstring = Replace(vstring, vbTab, ";")
    Write #2, vstring
    End If
    Loop
    
    
    Close #1
    Close #2
    
    
    End Sub
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    use

    Sub M_snb()
       workbooks.open "C:\Users\" & Environ("USERNAME") & "\Desktop\source.csv"
    End Sub

  3. #3
    VBAX Regular mikke3141's Avatar
    Joined
    Jun 2007
    Location
    Klaukkala
    Posts
    53
    Location
    This other attachment test.csv does not load correctly with workbooks.open
    Attached Files Attached Files

  4. #4
    VBAX Regular sktneer's Avatar
    Joined
    Dec 2014
    Location
    Kanpur
    Posts
    6
    Location
    What do you mean by does not load correctly?
    The below code will open your test.csv saved on desktop without an issue.
    If problem is something else, please make it clear.

    Sub mikke()
        Workbooks.Open Environ("UserProfile") & "\Desktop\test.csv"
    End Sub
    Regard
    sktneer

Posting Permissions

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