Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating RTF in VB6 with FSO

Posted on 2015-01-24
4
Medium Priority
?
139 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 2000 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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

705 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