+ Reply to Thread
Results 1 to 12 of 12

Macro to Save as from HTML to XLS

  1. #1
    Registered User
    Join Date
    01-05-2013
    Location
    Lisbon
    MS-Off Ver
    Excel 2003
    Posts
    4

    Macro to Save as from HTML to XLS

    Hi all,

    I have a problem with files I extract automatically from a tool, which should save them as .XLS, but in fact saves in .HTML format.

    These are daily reports which at the end of the month populate another file, by using vlookup.

    Because the files are saved in html format, vlookup does not read them and I have to open each one and Save it as .xls

    What I would like to do is to create a macro which would open the folder where those files are and automatically save them into .xls with exactly the same name.

    Is there anyone who can assist me in doing this?

    Thank you for your assistance.
    Pedro

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to Save as from HTML to XLS

    attach please a html sample
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    01-05-2013
    Location
    Lisbon
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to Save as from HTML to XLS

    hi Patel,

    Thank you for your assistance. Here's the file which is created by my reporting tool.

    This is then saved into a folder, but when I open it it says it is in html format. Then I need to do a Save As xls and it becomes available for my other excel file to extract the necessary information.

    If you could assist with a macro which would allow me to open and save as all these documents I would really appreciate.

    thanks,
    pedro
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to Save as from HTML to XLS

    Why did you attach a xls file ?
    try this code
    Please Login or Register  to view this content.
    Last edited by patel45; 09-05-2013 at 12:25 PM.

  5. #5
    Registered User
    Join Date
    01-05-2013
    Location
    Lisbon
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to Save as from HTML to XLS

    Hi Patel,

    I probably did not explain correctly what is happening.

    I am extracting the file I sent to you and it actually saves as .xls because the script which makes the report dictates it should be saved with extension .xls, when in fact the format is .html

    Îf you try to open that file in excel you will receive a message stating that the file has been saved in a different format then the extension it has.

    I click 'Yes' to open the file and then to make a real .xls file I have to go to file, Save As, choose the Save As Type (which you will see shows as html) and then save it as .xls.

    That is what happens and I have to open 30 files every month and do this same action.

    Hope this has clarified and sorry for the time wasted.
    Pedro

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to Save as from HTML to XLS

    did you try my code ?

  7. #7
    Registered User
    Join Date
    01-05-2013
    Location
    Lisbon
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to Save as from HTML to XLS

    Hi Patel,

    Just tried it and it doesn't work, because it opens my file (changed the name and location) but crashes in the following line.

  8. #8
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to Save as from HTML to XLS

    you missed the error line

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

    Re: Macro to Save as from HTML to XLS

    All you need is code that opens the file and re-saves it. Are you doing this one by one or in a batch?

  10. #10
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to Save as from HTML to XLS

    yes, it's more simple
    Please Login or Register  to view this content.
    Last edited by patel45; 09-06-2013 at 04:34 AM.

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

    Re: Macro to Save as from HTML to XLS

    You'll obviously need to change the filename in Patel's code and replace the extension with xls

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro to Save as from HTML to XLS

    Please Login or Register  to view this content.



+ 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. Macro to open website (from Url in column A) and save as html
    By Flabbergaster in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-10-2013, 05:42 PM
  2. Macro to save workbook as html then open it in a browser.
    By brent_milne in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-25-2012, 03:53 PM
  3. Macro to select cells and save as html
    By itmanusa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-27-2010, 09:20 AM
  4. [SOLVED] Save Excel book as Html Page Using Macro
    By Excel in forum Excel General
    Replies: 3
    Last Post: 02-21-2006, 10:10 AM
  5. Save Excel book as Html Page Using Macro
    By bj in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2006, 07:10 PM

Tags for this Thread

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