SaadDani
asked on
converting MsWord doc to html dynamicly
I want to make possible to users to upload an MsWord document to my site and that the ASP application will convert the document to an HTML document in order that everyone will be able to read it. I have an uploading com for doing the uploading.
I am interested to get the code for doing the conversion.
The same for MsExcell files.
I am interested to get the code for doing the conversion.
The same for MsExcell files.
You could invoke the ole automation objetc model for word and do as saveas. Alternativley to this you could use a text conversion filter. keypak do one which can convert from many formats but could be overkill!!
deestuar,
Welcome to EE, and i look like your comments is no an ANSWER, please DONT LOCK the QUESTION!
SaadDani please reject the COMMENTS, i will tell you how to do it with asp.
Regards,
Wee Siong
Welcome to EE, and i look like your comments is no an ANSWER, please DONT LOCK the QUESTION!
SaadDani please reject the COMMENTS, i will tell you how to do it with asp.
Regards,
Wee Siong
ASKER
weesiong
I did what you tell me to do and I am still waiting for your answer!!!
I did what you tell me to do and I am still waiting for your answer!!!
SaadDani,
Sorry forget in here, i will post you the code tomorrow, now i want goto sleep :)
Regards,
Wee Siong
Sorry forget in here, i will post you the code tomorrow, now i want goto sleep :)
Regards,
Wee Siong
SaadDani,
See this link:
http://support.microsoft.com/support/kb/articles/Q291/3/25.ASP
Regards,
Wee Siong
See this link:
http://support.microsoft.com/support/kb/articles/Q291/3/25.ASP
Regards,
Wee Siong
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got an error of nn compatibility of type on
wrd.Application.ActiveDocu ment.SaveA s
wrd.Application.ActiveDocu
SaadDani,
You are running in PWS, IIS or?
and make sure you have permission to Save the file, and also make sure you have Word install :)
Regards,
Wee Siong
You are running in PWS, IIS or?
and make sure you have permission to Save the file, and also make sure you have Word install :)
Regards,
Wee Siong
ASKER
I am running it on win2000 IIS, word2000 installed, where permission to save can be set?
SaadDani,
Sorry, i am no sure, i am testing in my PWS no any problem :)
Are you using the example i posted? the microsoft link i posted need to download the .exe file and install, but i no try it.
Regards,
Wee Siong
Sorry, i am no sure, i am testing in my PWS no any problem :)
Are you using the example i posted? the microsoft link i posted need to download the .exe file and install, but i no try it.
Regards,
Wee Siong
SaadDani,
And post me your code :)
Regards,
Wee Siong
And post me your code :)
Regards,
Wee Siong
ASKER
<%@ Language=VBScript %>
<% response.buffer = true
Response.CacheControl="no- cache"
Response.AddHeader "Pragma","no-cache"
Response.Expires=0
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-8">
</script>
</head>
<body bgcolor="azure">
<center>
<%
Dim mySmartUpload
Dim fileAlreadyExist
Dim connectionProblems
'On Error Resume Next
fileAlreadyExist = false
connectionProblems = false
Set mySmartUpload = Server.CreateObject("aspSm artUpload. SmartUploa d")
mySmartUpload.Upload
For each file In mySmartUpload.Files
Set fsoObject = Server.CreateObject("Scrip ting.FileS ystemObjec t")
'if fsoObject.FileExists("..\" & application("docsDirectory ") & docName & ".htm") then
if fsoObject.FileExists("c:\h averim\doc uments\" & file.FileName) then
fileAlreadyExist = true
else
if LCase(right(file.FileName, 4)) = ".doc" then
file.SaveAs("c:\haverim\do cuments\" & file.FileName)
newFileName = left(file.FileName, len(file.FileName) - 3) & "html"
Const wdFormatHTML = "8"
Set wrd = CreateObject("Word.Applica tion")
wrd.Documents.Open Server.MapPath("../documen ts/" & file.FileName)
wrd.Visible = False
wrd.Application.ActiveDocu ment.SaveA s Server.MapPath("../documen ts/" & newFileName), wdFormatHTML
wrd.Application.quit
Set wrd = Nothing
docName = newFileName
else
docName = file.FileName
end if
Set MyConnection = Server.CreateObject("ADODB .Connectio n")
MyConnection.Open "DSN=elecDB;UID=;PWD=pkuyu 9"
MySQL = "INSERT INTO tblDocuments (do_owner, do_name, do_sug) "
MySQL = MySQL & " VALUES (" & session("account") & ", '" & docName & "', "
MySQL = MySQL & session("sug") & ")"
'response.write(MySQL)
MyRS = MyConnection.Execute(MySQL , numofRec, adCmdText)
If MyConnection.Errors.Count > 0 Then
connectionProblems = true
end if
end if
next
if fileAlreadyExist then
response.write("?ca ?a?? e/?ca ?a ?a?? ?u?a ua i??? e/?ci ,?aaia iee? ?ae a? iua ?a??")
response.write("<p><a href='docs.asp'>a??c<a>")
elseif connectionProblems then
MyConnection.close
Response.Write("Problems with the database, come back later...")
response.write("<p><a href='docs.asp'>a??c<a>")
else
MyConnection.close
response.redirect("docs.as p")
end if
%>
<% response.buffer = true
Response.CacheControl="no-
Response.AddHeader "Pragma","no-cache"
Response.Expires=0
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-8">
</script>
</head>
<body bgcolor="azure">
<center>
<%
Dim mySmartUpload
Dim fileAlreadyExist
Dim connectionProblems
'On Error Resume Next
fileAlreadyExist = false
connectionProblems = false
Set mySmartUpload = Server.CreateObject("aspSm
mySmartUpload.Upload
For each file In mySmartUpload.Files
Set fsoObject = Server.CreateObject("Scrip
'if fsoObject.FileExists("..\"
if fsoObject.FileExists("c:\h
fileAlreadyExist = true
else
if LCase(right(file.FileName,
file.SaveAs("c:\haverim\do
newFileName = left(file.FileName, len(file.FileName) - 3) & "html"
Const wdFormatHTML = "8"
Set wrd = CreateObject("Word.Applica
wrd.Documents.Open Server.MapPath("../documen
wrd.Visible = False
wrd.Application.ActiveDocu
wrd.Application.quit
Set wrd = Nothing
docName = newFileName
else
docName = file.FileName
end if
Set MyConnection = Server.CreateObject("ADODB
MyConnection.Open "DSN=elecDB;UID=;PWD=pkuyu
MySQL = "INSERT INTO tblDocuments (do_owner, do_name, do_sug) "
MySQL = MySQL & " VALUES (" & session("account") & ", '" & docName & "', "
MySQL = MySQL & session("sug") & ")"
'response.write(MySQL)
MyRS = MyConnection.Execute(MySQL
If MyConnection.Errors.Count > 0 Then
connectionProblems = true
end if
end if
next
if fileAlreadyExist then
response.write("?ca ?a?? e/?ca ?a ?a?? ?u?a ua i??? e/?ci ,?aaia iee? ?ae a? iua ?a??")
response.write("<p><a href='docs.asp'>a??c<a>")
elseif connectionProblems then
MyConnection.close
Response.Write("Problems with the database, come back later...")
response.write("<p><a href='docs.asp'>a??c<a>")
else
MyConnection.close
response.redirect("docs.as
end if
%>
SaadDani,
The script no more problem, but:
Const wdFormatHTML = "8"
move outsite "FOR"
and tell me the fully error you got :)
Regards,
Wee Siong
The script no more problem, but:
Const wdFormatHTML = "8"
move outsite "FOR"
and tell me the fully error you got :)
Regards,
Wee Siong
ASKER
??uaeau ?ii ?eoa ui Microsoft VBScript (0x800A000D)
??ae-auaia ui ??a: 'wrd.Application.ActiveDoc ument.Save As'
/docs/doAddDoc.asp, line 49
this is in hebrew
the first error mean: run time error
the second one: non compatibility type
??ae-auaia ui ??a: 'wrd.Application.ActiveDoc
/docs/doAddDoc.asp, line 49
this is in hebrew
the first error mean: run time error
the second one: non compatibility type
SaadDani,
non compatibility type ==> Method Error or?
Why you dont want try do it in a short script to testing it can work first or not?
just using the example i posted and using this to testing it can work or not, this will easy debug :)
Regards,
Wee SIong
non compatibility type ==> Method Error or?
Why you dont want try do it in a short script to testing it can work first or not?
just using the example i posted and using this to testing it can work or not, this will easy debug :)
Regards,
Wee SIong
ASKER
I did it, (a short script, and got same result
regards
SaadDani
regards
SaadDani
ASKER
I canceled the line with the const and it works, but there is another problem now, the html file is unreadable...
May be it is because I try to convert a word97 file (but this is exacxtly what I want to do...)
regards
May be it is because I try to convert a word97 file (but this is exacxtly what I want to do...)
regards
ASKER
I tried also with a word2000 file where was written "Hello Word" and few more word and this is the junk I got in the html file
?Ia!?a>?y !#?yyy yyyyyyyyyyyyyyyyyyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyiYA7 ??0>bjbjUU . 7|7|yyyyyyl???????UNNNN Z U??rrrrrrrrdff ffff$ ? >P??rrrrr?I??r r?III r"?r?r dIrdI ?Id??dr f 3sv AUrN?dd?0?d ?( dI?I????UHello world Abcde eU?Y ??eUO (>uZ?o(&(>y yyyo$? ?A$> y,1?h ??. ??A!?"?#? $? %??A?A ?A i8@?y8 NormalCJ_H aJmH sH tH >> !! !yySaadC:\Haverim\documents\hello .docSaadC:\Haverim\documents\hello .htmly@?? M@yyUnknownyyyyyyyyy yyyG? ? z ?yTimes New Roman5??Symb ol3&? ?z ?yArial"q???h?[Wf?[ Wf !? '??r0e?yy Hello worldSaadSaad?ya??ouO h<?+'?U0 \??? ?AIa ?u $ 0<DLTc Hello worldellSaad woaad Normal.dotSaadl.d2adMicrosoft Word 9.0@@Z^W A@Z^W A?y?I??.??+ ,u?0o hp???? ??? A ?cSaado Hello world ui?yyy ?yyy?yyy?yyyyyyy"?yyy?yyy?yyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyR oot Entryyyyyyyyy AFp??v A$?1Tableyyyyyyyyyyyy WordDocume ntyyyy yyyySumm aryInforma tion(y yyyDocu mentSummar yInformati on8yyyyy yyyyyyy CompObj yyyyjObj ectPooly yyyyyyyyyy yp??v Ap??v Ayyyyyyyyyyyy?yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyyyyy yyyyyyy?y yyyy AFMicrosoft Word Document MSWordDoc
?Ia!?a>?y !#?yyy yyyyyyyyyyyyyyyyyyyyyyyyyy
SaadDani,
try this:
<%
Set wrd = CreateObject("Word.Applica tion")
wrd.Documents.Open Server.MapPath("aa.doc")
wrd.Visible = False
wrd.Application.ActiveDocu ment.SaveA s Server.MapPath("aa.html"), 8
wrd.Application.quit
Set wrd = Nothing
%>
Using "8", but i believe will get same problem :(
Regards,
Wee Siong
try this:
<%
Set wrd = CreateObject("Word.Applica
wrd.Documents.Open Server.MapPath("aa.doc")
wrd.Visible = False
wrd.Application.ActiveDocu
wrd.Application.quit
Set wrd = Nothing
%>
Using "8", but i believe will get same problem :(
Regards,
Wee Siong
SaadDani,
>I canceled the line with the const and it works, but there is another problem now, the html file is
unreadable...
You must Save the file as :
wrd.Application.ActiveDocu ment.SaveA s Server.MapPath("aa.html"), 8
8 means convert it to HTML format, Word97 convert, i no try before :(
Regards,
Wee Siong
>I canceled the line with the const and it works, but there is another problem now, the html file is
unreadable...
You must Save the file as :
wrd.Application.ActiveDocu
8 means convert it to HTML format, Word97 convert, i no try before :(
Regards,
Wee Siong
ASKER
Great, it works...
maybe can you provide the code for excell files also...
Thanks
Dani
maybe can you provide the code for excell files also...
Thanks
Dani
ASKER
maybe
Const wdFormatHTML = 8
was needed instead of
Const wdFormatHTML = "8"
Dani
Const wdFormatHTML = 8
was needed instead of
Const wdFormatHTML = "8"
Dani
ASKER
maybe
Const wdFormatHTML = 8
was needed instead of
Const wdFormatHTML = "8"
Dani
Const wdFormatHTML = 8
was needed instead of
Const wdFormatHTML = "8"
Dani
ASKER
Thank you very much
Const wdFormatHTML = 8
I found by myself for excel
Const wdFormatHTML = 8
I found by myself for excel
SaadDani,
Maybe you are right, but the first way also can working in me here :)
Excel --> HTML format, will you post other points?
Regards,
Wee Siong
Maybe you are right, but the first way also can working in me here :)
Excel --> HTML format, will you post other points?
Regards,
Wee Siong