Solved

excel to html including macro

Posted on 2014-02-10
6
382 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 80

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 80

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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 80

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now