Solved

excel to html including macro

Posted on 2014-02-10
6
388 Views
Last Modified: 2014-02-17
folks, I have excel vb code that calls URL's and obtains their status if the url is up or down, however I would like to publish this as html , how do I publish the excel as an html file but also include the macro in the sheet to re-run when I refresh the page?

all help will do

see sample attached
UPTIME-MONITOR--2-.xlsm
0
Comment
Question by:rutgermons
  • 3
  • 3
6 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39848623
I don't think you can run VBA code written for Excel on a HTML file.
You'll need to modify your code on the HTML to run javascript/php/asp etc.

HTH,
Dan
0
 
LVL 81

Expert Comment

by:byundt
ID: 39848885
In Excel 2003, you can save a file as .htm and it will retain multiple worksheets and VBA code.

In Excel 2007 and later, you will lose the VBA code.

So which version of Excel are you using?
0
 
LVL 81

Expert Comment

by:byundt
ID: 39848896
The following code is working in Excel 2003 with your workbook. It saves the workbook as "Uptime_Monitor_date_time.html" where date & time are determined programmatically. When I reopen the .html file, I can still run the workbook's macros.

I chose to modify the WriteStatus sub because that's the one that your command button was calling.
Public Sub WriteStatus()

    Dim R As Long
    Dim flPath As String, flName As String, sDate As String, sTime As String
    
    For R = 1 To Cells(Rows.Count, 1).End(xlUp).Row
            GetStatus Cells(R, 3).Address
    Next R
    flPath = "X:\VBA\Sample '14\"
    sDate = Format(Date, "yyyy-mm-dd")
    sTime = Replace(Format(Now(), "hh:mm"), ":", "-")
    flName = "Uptime_Monitor_" & sDate & "_" & sTime & ".html"
    ThisWorkbook.SaveAs flPath & flName, FileFormat:=xlHtml
    ' submit macro to run again in 5 min
    'Application.OnTime Now + TimeValue("00:05:00"), "WriteStatus"
End Sub

Open in new window

0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39849240
@byundt: you can actually run the code when opening the .htm with Internet Explorer?
0
 
LVL 81

Expert Comment

by:byundt
ID: 39849246
I'm opening the workbook and running the code in Excel 2003.

If I open the file in IE, the button doesn't do anything.
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39849371
OK, that's what I thought.
The way I understood the question, the OP wants to use a browser to open the html file created from Excel and run the embedded macros.
Hence my response: he can't.

Dan
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question