Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8154629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:25:03+00:00 2026-06-06T16:25:03+00:00

I need to convert html files to excel from time to time. There are

  • 0

I need to convert html files to excel from time to time. There are approximately 9000 html files that has tables on it.

I find it useful to convert them using excel 2007 vba, and made a macro to do the job, I have taken into account a bug of excel that halts the macro on Workbooks.Open function when SHIFT key is pressed, aside from that I disabled alerts, events and screen updating and make invisible the application as I don’t want to interrupt me while I do something else.

'Declare API
Declare Function GetKeyState Lib "User32" _
(ByVal vKey As Integer) As Integer
Const SHIFT_KEY = 16

Function ShiftPressed() As Boolean
'Returns True if shift key is pressed
    ShiftPressed = GetKeyState(SHIFT_KEY) < 0
End Function

Sub ConvertHtmlToExcel()
    Dim wb As Workbook
    Dim strFile As String
    Dim strPath As String

    With Application
        .EnableEvents = False
        .DisplayAlerts = False
        .ScreenUpdating = False
        .Visible = False
    End With

    strPath = "c:\FolderToConvert\"
    strFile = Dir(strPath & "*.html")

    Do While strFile <> ""
        Do While ShiftPressed()
            DoEvents
        Loop
        Set wb = Workbooks.Open(strPath & strFile)
        strFile = Mid(strFile, 1, Len(strFile) - 5) & ".xls"
        wb.SaveAs strPath & strFile, XlFileFormat.xlWorkbookNormal
        wb.Close
        Set wb = Nothing
        strFile = Dir
    Loop

    With Application
        .EnableEvents = True
        .DisplayAlerts = True
        .ScreenUpdating = True
        .Visible = True
    End With
End Sub

The macro seems to be fine but when running I have the following conversion rate per minute:

  1. 40
  2. 31
  3. 25
  4. 21
  5. 19
  6. 18

And it keeps decreasing right now after 500 file converted its current rate is 8 per minute.

After 2359 files the rate decreased to 2 per minute, when testing I had visible = true and saw that it took more time to OPEN the workbook.

So the problem seem to be on Workbooks.Open that at the beginning of the loop works as fast as it can but in further loops it starts to slow down.

Has anyone stumbled on this? Are there any workaround? Is my code missing something? And sometimes the macro still halts the execution I assume that the shift key wasn’t catched by that function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:25:05+00:00Added an answer on June 6, 2026 at 4:25 pm

    There is no standard way to override the “shift bypass” function within Excel (in contrast to the “AllowByPassKey” property in Access).
    If you have problems with the code you applied (I haven’t tried it), have you considered creating an add in?

    http://msdn.microsoft.com/nl-nl/library/aa671739(v=vs.71).aspx
    On the Microsoft site is explicitly mentioned:

    Several characteristics distinguish an Excel add-in from a typical workbook file:

    • Users cannot use the SHIFT key to bypass events that are built into the add-in. This feature makes sure any event procedures you have written in the add-in will run at the proper time.

    Regarding the speed: you seem to correctly allocate (.open) and release (set to nothing) memory for the “workbook” object in the loop so the memory it takes in the RAM should not increase or slow down during the processes.

    This interesting thread could provide an explanation:

    http://www.add-ins.com/support/out-of-memory-or-not-enough-resource-problem-with-microsoft-excel.htm

    “The conclusion we reached from the above testing is that VBA add-ins do not use a significant amount of memory. Workbooks are the major user of memory. And Excel does not release all memory when workbooks are closed. Which supports one approach of closing and restarting Excel after doing a lot of work. You should close and re open Excel at least once every two hours.”

    Perhaps it is worth the try to each time set a new application and using application.quit, which clears the entire Excel application used from memory.

     Dim appExcel As Excel.Application
    
     Set appExcel = CreateObject("Excel.Application")
     appExcel.Workbooks.Add
     'Do smtg
     appExcel.Quit
    

    Hope this works out for you! Interesting question!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There has been times where I need to convert an old HTML structure to
I need to convert HTML documents (generated from DocBook XML documents) to the Wiki
I need to convert HTML to PDF on the fly from a hosted ASP
I need to be able to convert dynamic HTML (html that is rendered on
I have an HTML help system that I need to convert to SharePoint. The
I have many html files in nested directories which I need to convert to
I have a large number of HTML files that I need to process with
I have a bunch of html files and need to convert and format them
I need to convert a time difference (diff) between two actions into a human
I need to convert a Joda-Time DateTime into a String, in the following format:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.