Solved

HTML Page On The Fly via VBA

Posted on 2012-03-14
2
227 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

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.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

739 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