CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2001
    Location
    Shenyang, Liaoning, China
    Posts
    2

    VBA and Excel macros

    I would like to write macro to convert .txt file to .xls file. Basically, I wrote a batch file to run Ping Test for all the IP addresses. The output of all of them goes to another .txt file. I would like to make a report for all the IP address and status of its PING TEST. So, can any body guide me here?

    thanks
    jigskins

    kjshelat

  2. #2
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: VBA and Excel macros

    The easiest way is to arrange the data in a comma delimited format and using .csv as the extension of the file. Excel should be set to open .CSV file automatically and format the data (column wise) based on the comma. Consider the following:


    option Explicit

    ' array to hold the computer names
    dim szComputers(30) as string

    private Sub DoPing()
    ' open the output file
    open "ping_results.csv" for output as #1

    dim i as Integer
    dim bStatus as Boolean

    ' loop through the comptuer names
    for i = 1 to UBound(szComputers)
    ' Assume PingComp() will return true if destination replied, false otherwise
    bStatus = PingComp(szComputers(i))

    ' write to the file - Chr(44) is a comma
    print #1, szComputers(i) & Chr(34) & CStr(bStatus)
    next i

    ' close the file
    close #1
    End Sub




    -Cool Bizs

    Good Luck,
    -Cool Bizs

  3. #3
    Join Date
    May 2001
    Location
    Shenyang, Liaoning, China
    Posts
    2

    To do programm for Ping Test

    Well, My problem is I want to retrieve data from .txt file. The program's requirement is create an application to do the ping test for different IP addresses. and show results in this manner that it comes in good table format.

    kjshelat

  4. #4
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: To do programm for Ping Test

    So which part is the problem? Reading from the file for the computer names? Doing the Ping itself? Or Writing the output back to a file?

    -Cool Bizs

    Good Luck,
    -Cool Bizs

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured