Solved

HTML Page On The Fly via VBA

Posted on 2012-03-14
2
228 Views
Last Modified: 2012-08-14
Hello Everyone
   Is there a way to create an basic web page via VBA without creating a notepad doc and saving it?

Sample:

<!DOCTYPE html>
<html>
     <body>
         <p>Hello World</p>
   </body>
</html>

If so could you provide an example?
0
Comment
Question by:Friggin_Lazy
[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
2 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 37722950
You would have to save/create the file somehow.

If you don't want to use Notepad*  you could just use VBA file I/O functions to create the file.

Something like this perhaps.
Sub CreateHTMLDoc()
Dim strFilename As String
Dim strHTML As String
Dim FF As Integer

    strFilename = "C:\testdoc.html"
    
    strHTML = "<!DOCTYPE html><html>     <body>         <p>Hello World</p>   </body></html>"

    FF = FreeFile
    
    Open strFilename For Output As #FF
    
        Print #FF, strHTML
        
    Close #FF
    
    ThisWorkbook.FollowHyperlink strFilename
    
End Sub

Open in new window


The HTML is hardcoded in one string but you could easily build it using VBA functions.

* Not actually sure how you would use Notepad to create an HTML document from VBA.
0
 
LVL 14

Expert Comment

by:Zack Barresse
ID: 37723103
* Not actually sure how you would use Notepad to create an HTML document from VBA.
Just write to a notepad text file, can be any .txt file, then just change the extension to .htm, which you can use the Name method for that.  I don't know why you would want to, when you can just write to a .htm file, like the method you've shown.

Regards,
Zack Barresse
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

615 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