Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


VBS to output HTML

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,36235
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VBS to output HTML
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 VBS to output HTML - 7/16/2006 8:33:59 PM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Hi Guys,
This is my first post here I do hope im in the correct section, I did think this may have to go into ASP but is mainly on VBS I think

Anyway...

Im about to have an attempt at a small web application that will take data from a user and then out put the data in an HTML page for the user to use on their own website or intranet..

I have yet to start this but know I Can do most of this...

I can set a form to take the users data and can then take that data and format it an display it in the tables etc required no probs!!

But how do I take this and either allow the user to save it as an HTML page or generate the HTML for them to copy and paste??

Its quite a complex table that will be generated and im just a little lost on this at the moment.

I think I will have to use Response.Write to spit out the code on the page for the user would that be right?  But how to do this im not to sure on?

I have not started any of this as yet as im just toying with it and cant work out how to do one little bit.
I do hope someone can advise me.
Many thanks
Tag
 
 
Post #: 1
 
 RE: VBS to output HTML - 7/16/2006 8:44:09 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
You need create an HTML file with the FileSystemObject and then, basically, write HTML code into it.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to tag2006)
 
 
Post #: 2
 
 RE: VBS to output HTML - 7/16/2006 8:52:31 PM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Thanks Ginolord

Can you point me to any examples of this and what all I need to consider to get this running, I know I can use FSO on my server so that will be ok for me.

I dont want to keep the HTML file once the user generates his page I want it to be emailed to them or have the HTML generated for them in a Text Area or something so they can copy and paste the HTML into their own pages??

Im not sure what the most efficient method would be? perhaps I could do both?

But an example of creating HTML would be brill if anyonce and show me....

Thank you again
Tag

(in reply to ginolard)
 
 
Post #: 3
 
 RE: VBS to output HTML - 7/16/2006 11:05:57 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Well, this for example, will create an HTML file containing a single row, two cell table


      

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to tag2006)
 
 
Post #: 4
 
 RE: VBS to output HTML - 7/16/2006 11:38:04 PM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Thanks,

Its looking like I may just be able to do this if I can get my head round my table needed and get the varables in the right places.

Im going to have to make a start and play with your example to see if I can manage this.

The formatting of this line puzzles me a little can you help me here with all the quotes etc??
"<table width=" & """" & "100%" & """" & " border>"

Also, using this method relys on an HTML file residing on the server too huh? in this case its c:\temp\test.html

When opening this file for writting will it clear the file of anything in that file when it writes or am I going to need to clear the file before I write to it?

Sorry for all the questions.
I do have a few VBS books im going to have to have a look at them once I see what i need to do.

Thanks very much
Tag

(in reply to ginolard)
 
 
Post #: 5
 
 RE: VBS to output HTML - 7/17/2006 12:02:56 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
quote:

ORIGINAL: tag2006

The formatting of this line puzzles me a little can you help me here with all the quotes etc??
"<table width=" & """" & "100%" & """" & " border>"


Perhaps this reformatted code will help. I don't know if it is a standards violation or not (too lazy to look it up right now) but HTML will allow tag attributes to be single quoted which makes it much easier to avoid the VB double quote nightmare:

      

quote:


Also, using this method relys on an HTML file residing on the server too huh? in this case its c:\temp\test.html


You are not required to do this in a seperate file. You could just as easily write the exact same strings to a text area then copy and paste it. I think ginolard just did it as a text file because it is quicker for demonstation purposes.

quote:


When opening this file for writting will it clear the file of anything in that file when it writes or am I going to need to clear the file before I write to it?


Yes it will because of:
Set HTMLFile = objFSO.OpenTextFile("c:\temp\test.html",ForWriting,True)

The WSH documentation will help a lot. You can find it by reading the Read Me First post that is pinned at the top of this forum.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to tag2006)
 
 
Post #: 6
 
 RE: VBS to output HTML - 7/17/2006 12:37:31 AM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Ah right OK, I didn't know HTML accepted single quotes.  Useful to know.  ebgreen's code is a lot more readable

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: VBS to output HTML - 7/17/2006 12:39:32 AM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
You could also make one massive string and paste it onto the clipboard (I've some code for that if you want it) but I think writing it to a file is probably safer.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to ginolard)
 
 
Post #: 8
 
 RE: VBS to output HTML - 7/17/2006 12:50:56 AM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Thanks Ginolard

Your posts are very helpfull to me thank you, I would be very intersted in the code example you mention as id like to give 2 options to the user either email an html file using the servers CDONTS or by spitting the needed HTML into a text area for the user to copy and paste.

This would be terrific If I can do both.

Im going to sit down and see if I can work this out I know I can do this I just have to see if I can generate my table properly and get my data into it properly this is my toughest callenge now I think.

Thank you again I will look out in this thread for your reply and will no doubt posts again.

Many Many Thanks
Tag

(in reply to ginolard)
 
 
Post #: 9
 
 RE: VBS to output HTML - 7/17/2006 12:59:16 AM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Here you go.  This will create a file and copy the same text to the clipboard


      

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to tag2006)
 
 
Post #: 10
 
 RE: VBS to output HTML - 7/19/2006 10:30:40 PM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Hi Guys,

Im struggeling a wee bit with a bit of this code, Initially im just trying to save an html file to the server then I will try and write my HTML to it..

But When im trying im getting an error I cant work out its goes like

Object required: 'WScript'

Can anyone suggest what im doing wrong? I have jusr used the test code you guys have posted to try it out a little so far..

Thanks again
Tag

(in reply to ebgreen)
 
 
Post #: 11
 
 RE: VBS to output HTML - 7/19/2006 10:38:00 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Post your code

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to tag2006)
 
 
Post #: 12
 
 RE: VBS to output HTML - 7/19/2006 10:42:42 PM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Hi Ginolard,

As I say I am just trying to create the HTML file so All I have on the page at the moment is

[code]

<%
Const ForWriting = 2
dim objFSO
dim HTMLFile
set objFSO = WScript.CreateObject("Scripting.FileSystemObject")  <<Errors out on this line
Set HTMLFile = objFSO.OpenTextFile("../test.html",ForWriting,True)
response.Write("HTML File Saved")
%>

[code]

(in reply to ginolard)
 
 
Post #: 13
 
 RE: VBS to output HTML - 7/19/2006 11:33:43 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
You can't use WSCRIPT in HTML/HTAs.  Remove and just use CreateObject("Scripting.FileSystemObject") instead

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to tag2006)
 
 
Post #: 14
 
 RE: VBS to output HTML - 7/20/2006 12:18:08 AM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Thanks GinoLard,

Now it errors on the next line and says permission denied.

Im trying to save the html file to the servers root dir and have chaged it to this

Set HTMLFile = objFSO.OpenTextFile("test.html",ForWriting,True)
I also tried

Set HTMLFile = objFSO.OpenTextFile("../test.html",ForWriting,True)

and

Set HTMLFile = objFSO.OpenTextFile("/test.html",ForWriting,True)

Is this the right syntax? I know I have write permission in my sites root dir and can use FSO

Thanks again
Tag

(in reply to ginolard)
 
 
Post #: 15
 
 RE: VBS to output HTML - 7/20/2006 8:48:13 AM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Hi Guys,
Im still not seeing whats up here ??
Can anyone advise me or point me to a tutorial on saving a file to the sites root and writting to it.
So far im just trying to create the HTML file and am still getting permission denied?

Thanks again
Tag

(in reply to tag2006)
 
 
Post #: 16
 
 RE: VBS to output HTML - 7/20/2006 8:50:30 AM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Hi Guys,
Im still not seeing whats up,
Can anyone point me to a tutorial on creating an html file in the sites root dir.
So far im just trying to make the HTML file and am getting permission denied?

Thanks again
Tag

(in reply to tag2006)
 
 
Post #: 17
 
 RE: VBS to output HTML - 7/20/2006 9:08:47 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
it looks like you are trying to do this via a web server/browser and i dont think you can do that

this forum is for windows scripting host scripts mostly.

_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to tag2006)
 
 
Post #: 18
 
 RE: VBS to output HTML - 7/20/2006 9:13:18 AM   
  tag2006

 

Posts: 9
Score: 0
Joined: 7/16/2006
Status: offline
Hi Thanks,
Im not to sure what the term windows scripting host scripts means but i will leave your forum now.
Thank you.
Regards
Tag

(in reply to kirrilian)
 
 
Post #: 19
 
 RE: VBS to output HTML - 7/20/2006 3:48:29 PM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
If I am wrong please correct me but when I see response.Write("HTML File Saved") between <% %> tags that means ASP. And as far as I know you cant do any file writes/reads using the standard VBS FSO function in ASP.

_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to tag2006)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VBS to output HTML Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts