Solved

Creating RTF in VB6 with FSO

Posted on 2015-01-24
4
134 Views
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 ("----------------------------------------------------------------------------")
           Else
                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 ("}")
        a.Close
        Set a = Nothing
        Set fs = Nothing

Open in new window

0
Comment
Question by:Bob Schneider
[X]
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
4 Comments
 
LVL 45

Accepted Solution

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

Author Comment

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

Assisted Solution

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

Author Closing Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 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