aspnewbie
asked on
Open Excel and powerpoint document.
how to open excel and powerpoint document?? and save it as .html
but it seems it needs an activex to be set on the client..
ASKER
since there is no solution for this, i will change the topic to:
In word to open document using this component
set wrd =CreateObject("Word.Applic ation")
then what about in excel and powerpoint?? I need it to open and then save as .html format
thank you
aspnewbie
In word to open document using this component
set wrd =CreateObject("Word.Applic
then what about in excel and powerpoint?? I need it to open and then save as .html format
thank you
aspnewbie
Ehh.. EE policies forbid the renaming of already answered questions.. but anyways I'll try to help you in the second question..
Dynamic excel example:
http://www.aspalliance.com/stevesmith/articles/exceltutorial.asp
More codes:
http://www.aspin.com/home/tutorial/document/xls
now I guess you want to flush the documents in the browser context to the client then try:
you'll need to send the file content in a stream.. if the client has the appropriate application installed
then it'll open in the browser, otherwise the user will get a save prompt this will open an excel file:
<%
Response.ContentType = "application/vnd.ms-excel"
' contents here...
set objBinaryFile = Server.CreateObject("Binar yFileStrea m.Object")
Response.BinaryWrite objBinaryFile.GetFileBytes (CStr(strF ilePathAnd Name))
set objBinaryFile = nothing
%>
BinaryFileStream object dll can be found here:
http://download.microsoft.com/download/excel2000/sample/2000/w9x2k/en-us/ChartGIF.exe
you'll need to set the proper mime type for each application document or the file will be prompted to
save. also the IUSR will need NTFS read permissions on these files
You can also open the file as an ado stream..
her's a link of common mime types.. you can set a function to assosiate each file extention to a mime
type response..
http://hostutopia.com/support/s058.html
Dynamic excel example:
http://www.aspalliance.com/stevesmith/articles/exceltutorial.asp
More codes:
http://www.aspin.com/home/tutorial/document/xls
now I guess you want to flush the documents in the browser context to the client then try:
you'll need to send the file content in a stream.. if the client has the appropriate application installed
then it'll open in the browser, otherwise the user will get a save prompt this will open an excel file:
<%
Response.ContentType = "application/vnd.ms-excel"
' contents here...
set objBinaryFile = Server.CreateObject("Binar
Response.BinaryWrite objBinaryFile.GetFileBytes
set objBinaryFile = nothing
%>
BinaryFileStream object dll can be found here:
http://download.microsoft.com/download/excel2000/sample/2000/w9x2k/en-us/ChartGIF.exe
you'll need to set the proper mime type for each application document or the file will be prompted to
save. also the IUSR will need NTFS read permissions on these files
You can also open the file as an ado stream..
her's a link of common mime types.. you can set a function to assosiate each file extention to a mime
type response..
http://hostutopia.com/support/s058.html
aspnewbie,
Easy, faster way for word:
<%
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
%>
For the power point
<%
Set Wrd = CreateObject("PowerPoint.A pplication ")
Wrd.Presentations.Open (Server.MapPath("power.ppt "))
wrd.Visible = False
wrd.Application.ActivePres entation.S aveAs Server.MapPath("aa.html"), 8
wrd.Application.quit
Set wrd = Nothing
%>
Regards,
Wee Siong
Easy, faster way for word:
<%
Set wrd = CreateObject("Word.Applica
wrd.Documents.Open Server.MapPath("aa.doc")
wrd.Visible = False
wrd.Application.ActiveDocu
wrd.Application.quit
Set wrd = Nothing
%>
For the power point
<%
Set Wrd = CreateObject("PowerPoint.A
Wrd.Presentations.Open (Server.MapPath("power.ppt
wrd.Visible = False
wrd.Application.ActivePres
wrd.Application.quit
Set wrd = Nothing
%>
Regards,
Wee Siong
aspnewbie,
IF in the Excel:
<%
Set Wrd = CreateObject("Excel.Applic ation")
Wrd.Presentations.Open (Server.MapPath("excel.xls ")).Activa te
wrd.Visible = False
wrd.Application.ActiveWork book.SaveA s Server.MapPath("aa.html"), 8
wrd.Application.quit
Set wrd = Nothing
%>
Regards,
Wee Siong
IF in the Excel:
<%
Set Wrd = CreateObject("Excel.Applic
Wrd.Presentations.Open (Server.MapPath("excel.xls
wrd.Visible = False
wrd.Application.ActiveWork
wrd.Application.quit
Set wrd = Nothing
%>
Regards,
Wee Siong
I agree with weesiong, but it is a really bad idea to do this. If
any errors occur, they will do server-side, and any resulting dialogue boxes will be invisible to the
user. These errors can drain the server's resources, and in some cases, crash the server. A number of
Microsoft KnowledgeBase articles warn against the practice.
You would be much better off if you could find a way to generate txt files using the Scripting.FileSystemObject
as you can more easily trap errors and release errant objects.
Fritz the Blank
any errors occur, they will do server-side, and any resulting dialogue boxes will be invisible to the
user. These errors can drain the server's resources, and in some cases, crash the server. A number of
Microsoft KnowledgeBase articles warn against the practice.
You would be much better off if you could find a way to generate txt files using the Scripting.FileSystemObject
as you can more easily trap errors and release errant objects.
Fritz the Blank
ASKER
Anything wrong with the code:
<%
Set Wrd = CreateObject("powerpoint.A pplication ")
Wrd.Presentations.Open ("d:\test.ppt")
wrd.Visible = False
wrd.Application.ActivePres entation.S aveAs "d:\test.html", 8
wrd.Application.quit
Set wrd = Nothing
%>
this is the error:
Error Type:
Microsoft PowerPoint 2002 (0x80048240)
Presentations.Open : Invalid request. The PowerPoint Frame window does not exist.
/test.asp, line 3
<%
Set Wrd = CreateObject("powerpoint.A
Wrd.Presentations.Open ("d:\test.ppt")
wrd.Visible = False
wrd.Application.ActivePres
wrd.Application.quit
Set wrd = Nothing
%>
this is the error:
Error Type:
Microsoft PowerPoint 2002 (0x80048240)
Presentations.Open : Invalid request. The PowerPoint Frame window does not exist.
/test.asp, line 3
aspnewbie,
Sorry something error in Excel format:
The correct one
<%
Set Wrd = CreateObject("Excel.Applic ation")
Wrd.Workbooks.Open (Server.MapPath("excel.xls ")).Activa te
wrd.Visible = False
wrd.Application.ActiveWork book.SaveA s Server.MapPath("aa.html"), 8
wrd.Application.quit
Set wrd = Nothing
%>
Regards,
Wee Siong
Sorry something error in Excel format:
The correct one
<%
Set Wrd = CreateObject("Excel.Applic
Wrd.Workbooks.Open (Server.MapPath("excel.xls
wrd.Visible = False
wrd.Application.ActiveWork
wrd.Application.quit
Set wrd = Nothing
%>
Regards,
Wee Siong
aspnewbie,
this is the error:
Error Type:
Microsoft PowerPoint 2002 (0x80048240)
Presentations.Open : Invalid request. The PowerPoint Frame window does not exist.
/test.asp, line 3
>>When you run the script, please make sure you have close the powerpoint windows.
REgards,
Wee Siong
this is the error:
Error Type:
Microsoft PowerPoint 2002 (0x80048240)
Presentations.Open : Invalid request. The PowerPoint Frame window does not exist.
/test.asp, line 3
>>When you run the script, please make sure you have close the powerpoint windows.
REgards,
Wee Siong
ASKER
powerpoint: yes, i have close the powerpoint windows.
excel: it can save, but the contents is strange. Besides that, there are few dialog box come out to save the multiple worksheet.
excel: it can save, but the contents is strange. Besides that, there are few dialog box come out to save the multiple worksheet.
aspnewbie,
Excel canot 100% convert to html, because if it got chart, it canot 100% convert to images.
The powerpoint i haven't try in here, but i think it should be work...... no sure, i will try it later.
Regards,
Wee Siong
Excel canot 100% convert to html, because if it got chart, it canot 100% convert to images.
The powerpoint i haven't try in here, but i think it should be work...... no sure, i will try it later.
Regards,
Wee Siong
ASKER
seems like naas1 face the same problem with me in powerpoint.
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20165294
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20165294
ASKER
siong: excel can convert to webpage by manually open excel file and then save as webpage.
So i think it can be done in asp as well.
Problem that i find in excel is not about chart. inside the excel file, i just test a normal string in 1 column.
So i think it can be done in asp as well.
Problem that i find in excel is not about chart. inside the excel file, i just test a normal string in 1 column.
aspnewbie,
Okes, i have see the problem, try this:
<%
On Error Resume Next
xlhtml = 44
Set Wrd = CreateObject("Excel.Applic ation")
Wrd.Workbooks.Open (Server.MapPath("excel.xls ")).Activa te
wrd.Visible = False
wrd.Application.ActiveWork book.SaveA s Server.MapPath("xlhtml.htm l"), xlhtml
wrd.Application.quit
Set wrd = Nothing
IF Err.Number > 0 Then
Err.Raise 6 ' Raise an overflow error.
Response.Write "Error # " & CStr(Err.Number) & " " & Err.Description
Err.Clear ' Clear the error.
End IF
%>
The power point version i will try in later.
Regards,
Wee Siong
Okes, i have see the problem, try this:
<%
On Error Resume Next
xlhtml = 44
Set Wrd = CreateObject("Excel.Applic
Wrd.Workbooks.Open (Server.MapPath("excel.xls
wrd.Visible = False
wrd.Application.ActiveWork
wrd.Application.quit
Set wrd = Nothing
IF Err.Number > 0 Then
Err.Raise 6 ' Raise an overflow error.
Response.Write "Error # " & CStr(Err.Number) & " " & Err.Description
Err.Clear ' Clear the error.
End IF
%>
The power point version i will try in later.
Regards,
Wee Siong
ASKER
well done siong....
by the way, what is the mistake??
i'll be waiting for the powerpoint :)
thanks
by the way, what is the mistake??
i'll be waiting for the powerpoint :)
thanks
aspnewbie,
The mistake because in each Office Tools got different code to convert to HTML exp: Word --> HTML using 8, Excel --> HTML using 44, Power Point --> HTML using ??, it make me trouble, so i am 1 by 1 to testing it :)
Regards,
Wee Siong
The mistake because in each Office Tools got different code to convert to HTML exp: Word --> HTML using 8, Excel --> HTML using 44, Power Point --> HTML using ??, it make me trouble, so i am 1 by 1 to testing it :)
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
well done.....
thanks a lot.
if u don't mind, may i know where you learn about this code?
thanks a lot.
if u don't mind, may i know where you learn about this code?
aspnewbie,
I mean learn this code from Microsoft Search, Yahoo Search, MSDN Search, EE Search, so this 1200 points no easy in me, but in last i also learn a new things :)
Regards,
Wee Siong
I mean learn this code from Microsoft Search, Yahoo Search, MSDN Search, EE Search, so this 1200 points no easy in me, but in last i also learn a new things :)
Regards,
Wee Siong
I'm new to ASP and am creating a document management system where I also need to convert powerpoint files to html. I've looked at the code above and am not sure how to incorporate it with files that the client uploads. Can someone help a newbie?
some FSO examples below:
<%
' create the fso object
set fso = Server.Createobject("Scrip
path = "c:\temp\test.txt"
strDate = Replace(Date(), "/", "")
strDir = "c:\inetpub\wwwroot\articl
strNewFileName = Hour(Now) & "_" & Minute(Now) & "_" & second(Now) & ".html"
' open the old file
set file = fso.opentextfile(path, 1) <-- For reading
strText = file.readall
set file = nothing
' check for and/or create folder
if not fso.folderexists(Server.Ma
set f = fso.CreateFolder(Server.Ma
else
set f = fso.GetFolder(Server.MapPa
end if
' create and write new file
set file = fso.Createtextfile(f.path & "\" & strNewFileName)
file.write(strText)
set f = nothing
file.close
set file = nothing
' delete the old file
fso.DeleteFile(path & "\" & rst("FileName") & i)
' clean up
set fso = nothing
%>
also check these links for more:
http://www.4guysfromrolla.com/webtech/090599-1.shtml
http://www.15seconds.com/Issue/000816.htm
http://msdn.microsoft.com/library/devprods/vs6/vbasic/vbenlr98/vaobjfilesystemobject.htm