+ Reply to Thread
Results 1 to 5 of 5

Save a (binary) file as string in code and write to disk when needed.

  1. #1
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Save a (binary) file as string in code and write to disk when needed.

    Hi all,

    I have a binary file which I
    a) want to save in the excel file as a string (decimal? hex? list of ascw codes?)
    b) write to disk and then be able to execute

    So imagine a file "blah.exe" which is 100bytes long; how could I best put this into a readable string into VBA so I can save it in the code and write to disk when needed?
    Thanks!

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Save a (binary) file as string in code and write to disk when needed.

    Read it in as an array of bytes (using Open and Get) and then output whenever needed using Open and Put.
    Rory

  3. #3
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Save a (binary) file as string in code and write to disk when needed.

    I am using these 2 to save GIF as string and creating/saving GIF into temp dir.

    I am not sure that will be working with exe but you can try.


    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  4. #4
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Save a (binary) file as string in code and write to disk when needed.

    Thank you - I guess that can work if I just save the ascw codes into a string rather than in a bunch of cells on a sheet.

  5. #5
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Save a (binary) file as string in code and write to disk when needed.

    That's not my code. I've found it somewhere. Maybe there was a reason why author split it into cells and I don't remember.
    However, it works for me.

+ 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. [SOLVED] save csv file as binary
    By charliec in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-25-2019, 01:05 PM
  2. [SOLVED] Trying to write code to save file as .csv
    By winwall in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2014, 10:44 AM
  3. VBA Code needed to disable the Save-As feature on any Excel 2003 file
    By alchavar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2013, 08:11 PM
  4. VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV
    By daleski in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 12:58 PM
  5. Write value to a txt-file as binary information?
    By jgeens in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2010, 09:15 AM
  6. [SOLVED] Computer freezes when i save excel file to floppy disk.
    By Christy in forum Excel General
    Replies: 8
    Last Post: 08-08-2006, 05:25 PM
  7. [SOLVED] Save a range to binary file (including its format)
    By Cool Sport in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2005, 10:06 AM

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