Solved

excel to html including macro

Posted on 2014-02-10
6
390 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

839 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