Solved

Creating RTF in VB6 with FSO

Posted on 2015-01-24
4
138 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 46

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 46

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
Suggested Courses
Course of the Month5 days, 20 hours left to enroll

626 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