Solved

Creating RTF in VB6 with FSO

Posted on 2015-01-24
4
125 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now