Creating RTF in VB6 with FSO

Posted on 2015-01-24
Last Modified: 2015-01-25
Ok my code worked just fine when i simply wanted to create a plain text file.  When I wanted to add line breaks I made some changes and now it is a jumbled in terms of new lines and tabs, etc.  If someone could tell me how I could get this to align I would appreciate it:

        fname = sPath & "Pursuit_Start_By_Gate_" & sRaceName & ".doc"
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set a = fs.CreateTextFile(fname, True)
        a.WriteLine ("{\rtf1")
        a.WriteLine (sMeetName & Space(1) & dMeetDate)
        a.WriteLine ("Pursuit Start By Gate for " & sRaceName)
        a.WriteBlankLines (3)
        a.WriteLine (sRaceName & " Pursuit Start By Gate")
        a.WriteBlankLines (2)
         For k = 0 To UBound(RunOrder, 2) - 1
            If k = 0 Then
                sCurrGate = RunOrder(5, k)
                a.WriteLine ("Gate " & sCurrGate)
                a.WriteBlankLines (1)
                a.WriteLine ("NO.   " & "RSTR-NAME" & Space(16) & vbTab & "TEAM" & Space(16) & vbTab & "BIB" & vbTab & "START" & vbTab & "GATE")
                a.WriteLine ("----------------------------------------------------------------------------")
                If RunOrder(5, k) <> sCurrGate Then
                    a.WriteLine ("\Page")
                    sCurrGate = RunOrder(5, k)
                    a.WriteBlankLines (3)
                    a.WriteLine ("Gate " & sCurrGate)
                    a.WriteBlankLines (1)
                    a.WriteLine ("NO.   " & "RSTR-NAME" & Space(16) & vbTab & "TEAM" & Space(16) & vbTab & "BIB" & vbTab & "START" & vbTab & "GATE")
                    a.WriteLine ("----------------------------------------------------------------------------")
                End If
            End If
            a.WriteLine (RunOrder(0, k) & RunOrder(1, k) & vbTab & RunOrder(2, k) & vbTab & RunOrder(3, k) & vbTab & RunOrder(4, k) & vbTab & RunOrder(5, k))
        Next k
        a.WriteLine ("}")
        Set a = Nothing
        Set fs = Nothing

Open in new window

Question by:Bob Schneider
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 45

Accepted Solution

aikimark earned 500 total points
ID: 40569090
Have you tried using the Write method instead of the Writeline method?

Author Comment

by:Bob Schneider
ID: 40569150
Do you mean a.Write("Hello World!")
LVL 45

Assisted Solution

aikimark earned 500 total points
ID: 40569346
yes.  Writeline appends a newline character at the end of whatever string you supply.

Author Closing Comment

by:Bob Schneider
ID: 40569525
Thank you very much.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
backup program with robocopy 6 71
Weighted Randomizing 6 32
Date on a table 16 34
Html split(text) 2 28
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question