Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Location
    Eastern Pennsylvania, Pennsylvania, USA
    Posts
    97
    Thanks
    0
    Thanked 0 Times in 0 Posts

    text file parse (vba)

    Hi,
    I have some textfiles to pick apart, and I could use a little help. After cleaning out the garbage characters, I am inserting a delimiter ( ` ) at the beginning of each string of text I want to read and then write it to a single line in a new text file. The string I want to keep varies in length.

    Essentially, I want to read the file character by character, and when hitting the delimiter, begin writing into a new file until hitting the delimiter again, then do a vbcrlf and write and so on...

    Any help is greatly appreciated.

    Thanks,
    Dave P.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: text file parse (vba)

    Is this file especially large? If it simply needs to be carved up based on a delimer, you could try creating a massive array of strings using the Split() method. (You need VBA 6.0 or higher, e.g., Office 2000 or higher.)

    Regarding the general mechanics of reading and writing files, the old "Basic" methods are okay, but the newer FileSystemObject methods are more full-featured. If you search this board for FileSystemObject you should find numerous snippets for reference, as well as links into the documentation on MSDN.

  3. #3
    Star Lounger
    Join Date
    Mar 2001
    Location
    Eastern Pennsylvania, Pennsylvania, USA
    Posts
    97
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: text file parse (vba)

    Thank you, JS...
    I have used Split(), and some serious string manipulation to accomplish what I needed. (sloppy, but it works)

    Thanks again,
    Dave P.

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: text file parse (vba)

    > and when hitting the delimiter, begin writing into a new file

    I do a lot of string parsing, and the attached file might give you some ideas. (strSplitAt, strSplitStringAt, strStripRight, strStripEnds)

    Paste the code into a template, drag out the commented TEST macro at the foot of a fucntion, de-comment it, then step through it to watch it work.

    As a programming practice, I try to generate internal delimited strings with the delimiter as the FIRST character, so that I can determine the delimiter character on-the-fly:
    <pre>Dim strDelim As String
    strDelim = Left$(strIn, 1)
    </pre>


  5. #5
    Star Lounger
    Join Date
    Mar 2001
    Location
    Eastern Pennsylvania, Pennsylvania, USA
    Posts
    97
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: text file parse (vba)

    Thanks Chris,

    I'll use these ideas to clean things up in the code. these files are as ugly as it gets, of course. Another issue I have is batch faxing with MS SBServer 2000. Have you any experience with this?

    Thanks again,
    Dave P.

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: text file parse (vba)

    > these files are as ugly as it gets

    Oh! We are working for the same client; let's meet in the cafeteria (grin!, and I really DO love my clients).

    > batch faxing with MS SBServer
    Not yet!

    I have devised various schemes for batch processing over the years, just not in MS SBS server. I'm keen on anything that reduces work and errors while maintaining the flow of money. I have written code to batch fax data to and from fax packages such as QuickLinkII. What's the nature of the problem?

  7. #7
    Star Lounger
    Join Date
    Mar 2001
    Location
    Eastern Pennsylvania, Pennsylvania, USA
    Posts
    97
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: text file parse (vba)

    Gotta love clients! If it weren't for them, I'd have to only work 40 hrs a week....

    Faxing - my current project is 7 local workstations hitting on a server (sbs2000) and 1 remote station doing a VPN over broadband (which works better than I thought). All will be using an access app linked to a tables only access db. Each station needs to fax reports to one or more fax numbers. I'm trying to bypass the wizard so a user can choose one to five names and fax the report they are viewing. This would loop and go into the fax que and then it would send until it is done.

    I've been trying the attached code on the server alone and it hangs at the "send" command and does not even initiate the modem. Any thoughts on this?

    Thanks,
    Dave P.

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: text file parse (vba)

    > hangs at the "send" command and does not even initiate the modem

    I have, as yet, no experience in sending directly to fax. I thought that a solution might be to print-to-fax. Here's a recorded macro of me printing a page and sending it to the fax-as-printer.

    It's not enough; obviously I need to communicate a telephone number, name, contact etc, just as I would when using an emailer.

    I do send email from Word documents through Outlook and Eudora; how much more difficult can faxing be?
    I'll try to take a look at it this week.


    <pre>Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 05/03/04 by Christopher Greaves
    '
    ActivePrinter = "Quick Link II Fax"
    Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
    wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
    Collate:=True, Background:=True, PrintToFile:=False
    End Sub
    </pre>


  9. #9
    Star Lounger
    Join Date
    Mar 2001
    Location
    Eastern Pennsylvania, Pennsylvania, USA
    Posts
    97
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: text file parse (vba)

    I've automated emails as well, but this seems to be a new beast. I'm spending a good deal of time on it this week, and will let you know. Thank you,
    Dave P.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •