+ Reply to Thread
Results 1 to 5 of 5

Reading From HTM Files

  1. #1
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Reading From HTM Files

    I am in the process of creating a program that has to read a number of .HTM files.
    These files can be opened with Excel. I need to open all files within same directory [approx. 370 files]. Read a few cells from each file and create a summary sheet in Excel.
    I don't see any examples for this file type here.

    I also have a question: In some of the codes I have seen here and used them successfully, I see a variable/attribute "vbDirectory". What is it and does it represent the file type?

    I am just getting started, so any help or guidance will be very helpful.

    Thanks,
    modytrane
    Last edited by modytrane; 06-23-2009 at 12:09 PM. Reason: email notification

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Reading From HTM Files

    Hello modytrane,

    I assume your talking about using the Dir to function to identify whether a string is a valid directory.

    Syntax
    Dir [(pathname[, attributes])]

    The attributes argument settings are:
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Reading From HTM Files

    Thanks Leith,
    That's very helpful in understanding the DIR function.

    Now the original question in my post.
    I have a number of .HTM files [all in one directory].

    I can open these files with Excel and they automatically open as .xls files.
    I can access the data by referencing cells etc.

    When I try to open them from within VBA, they open as webpages and I can't access data.

    From VBA, can I force the system to use Excel to open them?

    I have sort of figured out a workaround [not implemented yet].
    I can use Name function to change the file extension from .HTM to .XLS and then open them from VBA. But I am not sure if this is the right way to approach the problem.

    Thanks again for your help.
    modytrane

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Reading From HTM Files

    Hello modytrane,

    To open the .htm file in Excel, use the Workbooks.Open method.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Reading From HTM Files

    Leith,
    When I open the .HTM file with that command, it opens as a Web Page.
    I want to open it as an excel file, so I can copy certain cells from it. Can I force Excel to open it. It works when I open it manually from the Excel program.
    Thanks,
    modytrane

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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