Solved

excel to html including macro

Posted on 2014-02-10
6
391 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

730 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