+ Reply to Thread
Results 1 to 7 of 7

Writing and reading datafiles

  1. #1
    Registered User
    Join Date
    08-30-2014
    Location
    Lincoln, England
    MS-Off Ver
    Office 365
    Posts
    74

    Writing and reading datafiles

    This isn't a specific coding question, but I am looking to write and read datafiles to disk. The data would be fairly simple, taken from and then read back into a worksheet, so a mixture of text and numbers. I've been scouring the net to see where to start but wonder if someone can point me in the right direction - an article, a post, a url - anything relevant. I came across Microsoft Scripting which seems straightforward but I think is out of date and probably only for text. That's it. Any suggestions would be useful.
    Thanks.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Writing and reading datafiles

    Microsoft Scripting is fine, it's all out of date VB6 has been essentially dead for years

    What do you mean "only for text", you're writing to a text file? So that should be fine, or were you also wanting to write binary objects?

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Writing and reading datafiles

    Microsoft Scripting is fine, it's all out of date VB6 has been essentially dead for years

    What do you mean "only for text", you're writing to a text file? So that should be fine, or were you also wanting to write binary objects?

  4. #4
    Registered User
    Join Date
    08-30-2014
    Location
    Lincoln, England
    MS-Off Ver
    Office 365
    Posts
    74

    Re: Writing and reading datafiles

    Quote Originally Posted by Kyle123 View Post
    Microsoft Scripting is fine, it's all out of date VB6 has been essentially dead for years

    What do you mean "only for text", you're writing to a text file? So that should be fine, or were you also wanting to write binary objects?
    The data would be, as I said, a mixture of spreadsheet information, so you tell me, would it be better to write as a binary file or can it be done with a text file. I'm looking for help here, not a third degree grilling. Thanks, I think.

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Writing and reading datafiles

    I'm hardly "grilling" you, just trying to understand what you're actually trying to do so we can actually offer some help; you didn't clarify, your question is unclear so drop the 'tude

    I suspect that you just want a text file, they can hold numbers and strings - as to how you store it, you're probably better off using an already established format as there will be libraries to make reading and writing easier. CSV and XML spring to mind as possible options. Excel files >2003 are XML files (if you want to have a look, change an excel file extension form .xlsx to .zip, open it up and have a dig).

    CSV is theoretically simpler and a flat structure, but surprisingly tricky to write, Excel will export a sheet to csv though so this may be a good option - you can also use ADO to read them which can make things a breeze if you're thinking of putting in a lot of info.

    There isn't really a one size fits all format, that's why there are so many different formats and extension, it really depends on what you want to do with these files after they've been made and how your data is structured, does that help any?

  6. #6
    Registered User
    Join Date
    08-30-2014
    Location
    Lincoln, England
    MS-Off Ver
    Office 365
    Posts
    74

    Re: Writing and reading datafiles

    I'll try Microsoft Scripting for writing and reading text files and see how I get on. This is the link:
    https://msdn.microsoft.com/en-us/lib...=vs.84%29.aspx
    Not sure how the text is read into Excel but there should be a way.
    Thank you.

  7. #7
    Registered User
    Join Date
    08-30-2014
    Location
    Lincoln, England
    MS-Off Ver
    Office 365
    Posts
    74

    Re: Writing and reading datafiles

    I didn't want to leave this post unsolved, just in case anyone comes across it in desperate need. I used Microsoft Scripting system to do the deed. Use the link above to find out more. This has to be selected from the Tools-Reference list in VBA (not Excel). If you don't do this, the code will show error after error. Below is a simplified version of the code to write data from 15 columns to an arbitrary number of rows. If you have fixed numbers of rows and columns, this makes the task much easier:
    Please Login or Register  to view this content.
    I hope this helps someone, someplace, sometime...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Reading/writing MP3 properties with Excel VBA
    By msrikanthjobs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2012, 12:11 PM
  2. VBA Chart - Reading and Writing MajorGridlines
    By revector in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2008, 12:37 AM
  3. Reading / Writing to files
    By bobdylan75 in forum Excel General
    Replies: 1
    Last Post: 05-25-2008, 04:21 PM
  4. Problems with reading / writing ini-file
    By Youp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2006, 06:40 AM
  5. Reading Writing Data from One WorkBook to Another
    By John Pierce in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-30-2005, 05:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1