Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compile excel workbook to web page - is it possible

Status
Not open for further replies.

smurf01

IS-IT--Management
Jul 6, 2002
470
GB
Is it Possible to compile an excel spreadsheet into a web page
 
Of course, it's possible, but you need quite a much time to write the VBA compiler :)

At first, you should make a html page to make sure this is what you want to see and consider, which information will change (dynamic content) and which will remain untouched (static content).

Dependently on decision, you should copy each portion of the doc into parts stored as text files somewhere onto your HDD you (or users) can access.

Then you should write corresponding VBA code, which create a new, updated HTML file, including static content from text files and dynamic content from your worksheets.

For example, you want to build a simple web page which contains text "Hello, World! This is my first web page!"

So, the code of the page will look like:
<html>

<head>
<meta http-equiv=&quot;content-type&quot; content=&quot;text/html;charset=X-MAC-CENTRALEURROMAN&quot;>
<meta name=&quot;generator&quot; content=&quot;Adobe GoLive 5&quot;>
<title></title>
</head>

<body bgcolor=&quot;#ffffff&quot;>

<p>Hello, World! This is my first web page!</p>
</body>

</html>


The text in red is placed in file HTML_HEA.txt and in green - in file HTML_FOO.txt. The black text is dynamic content of web page and is into your workbook containig 2 sheets.
So, the VBA code will look like this

Dim strHTML as string

open &quot;C:\MyWebPage.html&quot; for output as #1
open &quot;C:\HTML_HEA.txt&quot; for input as #2
do until eof(2)
line input #2, strHTML
print #1, strHTML
loop
close #2

print #1, &quot;<p>&quot;
for each wsh in sheets
print #1, cells(1,1).text;
next
print #1, &quot;</p>&quot;
open &quot;C:\HTML_FOO.txt&quot; for input as #2
do until eof(2)
line input #2, strHTML
print #1, strHTML
loop
close

A little bit long, but can't be shorter.

Hope it helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top