Solved

excel to html including macro

Posted on 2014-02-10
6
393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 35

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

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 35

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

690 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