Home > Archive > ASP > March 2008 > Templates
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| shyPotter 2008-03-11, 6:57 pm |
| Hi all
I have to develop an application for client where I have a html template
file and a word document files as input files and I need to generate a html
files based on thes two input files . Word document may contain
images,table,links,text etc.
I am here to ask the Gurus advise.
Which language should I use ? I am thinking to develop as desktop
application using vb6.
How I can read the word document ?
Is not this good to use tags <!--teag1--> in html template file ?
How I can read the word document and what is best to know which text goes
where in html template ?
Thanks in Advance.
| |
| McKirahan 2008-03-11, 6:57 pm |
|
"shyPotter" <someone@noone.com> wrote in message
news:uS5uy$2gIHA.1212@TK2MSFTNGP05.phx.gbl...
> Hi all
>
> I have to develop an application for client where I have a html template
> file and a word document files as input files and I need to generate a
html
> files based on thes two input files . Word document may contain
> images,table,links,text etc.
>
> I am here to ask the Gurus advise.
>
> Which language should I use ?
> I am thinking to develop as desktop application using vb6.
I would recommend VBScript.
No compiling, no runtime, easily installed and maintained.
> How I can read the word document ?
Option Explicit
Const cDOC = "C:\your_document.doc"
Dim objMSW
Set objMSW = CreateObject("Word.Application.8")
Dim objDOC
Set objDOC = objMSW.Documents.Open(cDOC)
Dim strDOC
strDOC = objDOC.Content
objDOC.Close False
objMSW.Application.Quit True
Set objDOC = Nothing
Set objMSW = Nothing
MsgBox strDOC,vbInformation,WScript.ScriptName
> Is not this good to use tags <!--teag1--> in html template file ?
> How I can read the word document and what is best to know which text goes
> where in html template ?
I would use FSO to read the template file and save it as a variable.
It could contain a tag which would be replaced by the contents of each
document. Next, loop throught the folder containing the documents,
read each (as above), replace the tag with the contents and write out
an Web page (.htm) file.
| |
| Jeff Dillon 2008-03-11, 6:57 pm |
| You are aware that Word can save as HTML.
Jeff
"shyPotter" <someone@noone.com> wrote in message
news:uS5uy$2gIHA.1212@TK2MSFTNGP05.phx.gbl...
> Hi all
>
> I have to develop an application for client where I have a html template
> file and a word document files as input files and I need to generate a
> html files based on thes two input files . Word document may contain
> images,table,links,text etc.
>
> I am here to ask the Gurus advise.
>
> Which language should I use ? I am thinking to develop as desktop
> application using vb6.
> How I can read the word document ?
> Is not this good to use tags <!--teag1--> in html template file ?
> How I can read the word document and what is best to know which text goes
> where in html template ?
>
> Thanks in Advance.
>
>
>
>
| |
| Bob Barrows [MVP] 2008-03-11, 9:58 pm |
| McKirahan wrote:
> Dim objMSW
> Set objMSW = CreateObject("Word.Application.8")
To the OP: use this technique at your own risk in server-side code. MS
advises against it:
http://support.microsoft.com/defaul...kb;en-us;257757
Having said that, many people do successfully automate Office in server-side
code. This is just to make you aware of the risks.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
| |
| Adrienne Boswell 2008-03-12, 3:57 am |
| Gazing into my crystal ball I observed "Jeff Dillon"
<jeffdillon@hotmailremove.com> writing in
news:OVhw2o6gIHA.3940@TK2MSFTNGP05.phx.gbl:
> You are aware that Word can save as HTML.
>
Yes, with a lot of bloat and markup errors. I don't think so.
> "shyPotter" <someone@noone.com> wrote in message
> news:uS5uy$2gIHA.1212@TK2MSFTNGP05.phx.gbl...
>
>
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
| |
| McKirahan 2008-03-12, 3:57 am |
| "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:O2SBiu8gIHA.4140@TK2MSFTNGP04.phx.gbl...
> McKirahan wrote:
>
> To the OP: use this technique at your own risk in server-side code. MS
> advises against it:
> http://support.microsoft.com/defaul...kb;en-us;257757
>
> Having said that, many people do successfully automate Office in
server-side
> code. This is just to make you aware of the risks.
Bob, I was not thinking to run it within ASP but rather a standalone
VBS file to generate files to be uploaded to the Web site via FTP.
Though I am curious if the documents are actually content files
reeady for inclusion into a template...
| |
| Jeff Dillon 2008-03-12, 3:57 am |
| Which markup errors are you referring?
Jeff
"Adrienne Boswell" <arbpen@yahoo.com> wrote in message
news:Xns9A5EC413FA5A9arbpenyahoocom@69.28.186.121...
> Gazing into my crystal ball I observed "Jeff Dillon"
> <jeffdillon@hotmailremove.com> writing in
> news:OVhw2o6gIHA.3940@TK2MSFTNGP05.phx.gbl:
>
>
> Yes, with a lot of bloat and markup errors. I don't think so.
>
>
>
>
> --
> Adrienne Boswell at Home
> Arbpen Web Site Design Services
> http://www.cavalcade-of-coding.info
> Please respond to the group so others can share
>
| |
|
|
| Dave Anderson 2008-03-12, 6:57 pm |
| Adrienne Boswell wrote:
> Okay, I made two pages, one in Word and one with a plain text editor.
> All the page says is Hello World. That's it. Here's link to the
> validator showing errors.
>
> http://tinyurl.com/3e5xcl - W3 validator showing 6 errors for
> http://cavalcade-of-coding.info/usenet/hello.html - 104 lines ...
There's a funny circular error in there. Based on the omitted DOCTYPE
declaration, the validator assumes HTML 4.01 Transitional, which renders the
xmlns attribute illegitimate (it is *required* for XHTML). But if you choose
one of the XHTML DOCTYPEs, the number of errors shoots into the 40s.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
| |
| Jeff Dillon 2008-03-12, 6:57 pm |
| Got it. Scratch the Word-to-HTML suggestion :-)
Jeff
"Adrienne Boswell" <arbpen@yahoo.com> wrote in message
news:Xns9A5EF29559124arbpenyahoocom@69.28.186.121...
> Gazing into my crystal ball I observed "Jeff Dillon"
> <jeffdillon@hotmailremove.com> writing in news:e$4Vfo#gIHA.4164
> @TK2MSFTNGP05.phx.gbl:
>
>
> Okay, I made two pages, one in Word and one with a plain text editor.
> All the page says is Hello World. That's it. Here's link to the
> validator showing errors.
>
> http://tinyurl.com/3e5xcl - W3 validator showing 6 errors for
> http://cavalcade-of-coding.info/usenet/hello.html - 104 lines vs
> http://tinyurl.com/3awk2k - W3 validator showing 0 errors for
> http://cavalcade-of-coding.info/usenet/hello_valid.html - 12 lines.
>
> to
> text
>
>
>
> --
> Adrienne Boswell at Home
> Arbpen Web Site Design Services
> http://www.cavalcade-of-coding.info
> Please respond to the group so others can share
>
| |
| Dave Anderson 2008-03-12, 6:57 pm |
| Adrienne Boswell wrote:
> Okay, I made two pages, one in Word and one with a plain text editor.
> All the page says is Hello World. That's it. Here's link to the
> validator showing errors.
>
> http://tinyurl.com/3e5xcl - W3 validator showing 6 errors for
> http://cavalcade-of-coding.info/usenet/hello.html - 104 lines vs
It is worth pointing out that saving as [Web Page, Filtered] reduces this to
2 errors: No DOCTYPE and no TYPE on the STYLE element. At least, that is
true for Word 2003.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
| |
| shyPotter 2008-03-12, 6:57 pm |
| Hi,
Thanks for your support.
Can any of you give me a sample code I just want to make sure if I am not
heading wrong way. What I am using is
'Microsoft Word 10.0 Object Library
Set objWord = New Word.Application
Regards,
"Dave Anderson" <NPQRWPDWZGSP@spammotel.com> wrote in message
news:ejZPXrGhIHA.5368@TK2MSFTNGP04.phx.gbl...
> Adrienne Boswell wrote:
>
> It is worth pointing out that saving as [Web Page, Filtered] reduces this
> to 2 errors: No DOCTYPE and no TYPE on the STYLE element. At least, that
> is true for Word 2003.
>
>
>
>
> --
> Dave Anderson
>
> Unsolicited commercial email will be read at a cost of $500 per message.
> Use of this email address implies consent to these terms.
>
| |
| McKirahan 2008-03-12, 6:57 pm |
| "shyPotter" <someone@noone.com> wrote in message
news:OW#GKPIhIHA.6084@TK2MSFTNGP06.phx.gbl...
> Hi,
>
> Thanks for your support.
>
> Can any of you give me a sample code I just want to make sure if I am not
> heading wrong way. What I am using is
>
> 'Microsoft Word 10.0 Object Library
>
> Set objWord = New Word.Application
Will this help? Watch for word-wrap.
Save it as "template.vbs" in the same folder as your documents
and create your template file as "template.htm" which must contain
the tag "<?>" (per "cTAG") where you want the contents to go.
To execute it eiher doubleclick on it under Windows Explorer or,
from the command line, enter: "cscript.exe //nologo template.vbs".
The success of this approach depends on what your documents
contain. Inserting "WScript.Echo strDOC" after the "strDOC"
assignment may be helpful. Test with one document and post it.
Option Explicit
'****
'* This VBScript file does the following:
'* All files and documents are located in the current directory.
'* Read template "cTMP" and save its contents in "strOTF";
'* For each document and save its contents in "strDOC" then
'* create a Web page with the same name as the document but
'* with an ".htm" extension; the contents will contain "strCTF"
'* which is "strOTF" but with "cTAG" repalced with "strDOC".
'****
'*
'* Declare Constants
'*
Const cVBS = "template.vbs"
Const cTMP = "template.htm"
Const cDOC = ".doc"
Const cHTM = ".htm"
Const cTAG = "<?>"
'*
'* Declare Variables
'*
Dim intCTF
intCTF = 0
Dim strCTF
Dim strDIR
strDIR = WScript.ScriptFullName
strDIR = Left(strDIR,InStrRev(strDIR,"\"))
Dim strDOC
Dim strFIL
Dim strHTM
Dim strOTF
'*
'* Declare Objects
'*
Dim objCTF
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objDOC
Dim objMSW
Dim objOTF
'*
'* Read template
'*
Set objOTF = objFSO.OpenTextFile(strDIR & cTMP,1)
strOTF = objOTF.ReadAll
Set objOTF = Nothing
If InStr(strOTF,cTAG) = 0 Then
MsgBox cTAG & " not in " & cTMP,vbCritical,cVBS
WScript.Quit
End If
'*
'* Find documents and create Web pages
'*
For Each strFIL In objFSO.GetFolder(strDIR).Files
If LCase(Right(strFIL.Name,4)) = cDOC Then
strHTM = Left(strFIL.Path,Len(strFIL.Path)-4) & cHTM
'*
'* Read ".doc"
'*
Set objMSW = CreateObject("Word.Application.10")
Set objDOC = objMSW.Documents.Open(strFIL.Path)
strDOC = objDOC.Content
objDOC.Close False
objMSW.Application.Quit True
Set objDOC = Nothing
Set objMSW = Nothing
'*
'* Write ".htm"
'*
strCTF = Replace(strOTF,cTAG,strDOC)
If objFSO.FileExists(strHTM) Then
objFSO.DeleteFile(strHTM)
End If
Set objCTF = objFSO.CreateTextFile(strHTM)
objCTF.Write(strCTF)
Set objCTF = Nothing
intCTF = intCTF + 1
End If
Next
'*
'* Destroy Objects
'*
Set objFSO = Nothing
'*
'* Finish Message
'*
MsgBox intCTF & " Web pages created.",vbInformation,cVBS
|
|
|
|
|