Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert from html file to Excel

349 views
Skip to first unread message

Bojarajan

unread,
Jan 7, 2009, 12:35:57 PM1/7/09
to
Hi,

I am trying to convert the html file to Excel through powerbuilder, here is my
code
String docname
Int li_rtn
docname = "D:\Desktop\COMP_RPT.htm"

if dw_print_new.SaveAs(docname, HTMLTable!, True) = -1 then
MessageBox("Warning", "Unable to export data. Error writing to file!",
Exclamation!)
return
end if


// Convert HTML file to Excel native format


OLEObject excel
excel = CREATE OLEObject
li_rtn = excel.ConnectToObject(docname)
if li_rtn = 0 then
excel.application.DisplayAlerts = FALSE //getting error this code
excel.application.workbooks(1).Parent.Windows(excel.application.workbooks(1).Na
me).Visible = True
excel.application.workbooks(1).saveas(docname, 39)
excel.application.workbooks(1).close()
else
MessageBox("Error","OLE ConnectToObject return code = " +
string(li_rtn),Exclamation!)
end if
DESTROY excel

The above code is not working. It is generate the runtime error "Name not found
to accessing the external object properties".

Is there anyway to avoid this error and to process the html file to excel?
Please let me know if you have any ideas
Thanks
Bojarajan.
---== Posted via the PFCGuide Web Newsreader ==---
http://www.pfcguide.com/_newsgroups/group_list.asp

Brett Weaver

unread,
Jan 12, 2009, 4:02:33 PM1/12/09
to
A few things:
1.. You have not instantiated the Excel OLE connection. You need code like

OLEObject excel
excel = CREATE OLEObject
li_rtn = excel.ConnectToNewObject("excel.application")

2.. There are coding examples in the help for ConnectToNewObject and other
OLE methods which should help you

3.. Why are you saving as HTML and then inserting into Excel? Why not SaveAs
an Excel format?

"Bojarajan" <tboja...@gmail.com> wrote in message
news:4964e7fd$1@forums-1-dub...

Bojarajan

unread,
Jan 20, 2009, 11:21:54 AM1/20/09
to
Hi Brett,
Thanks for your response. I am trying to saveas the crosstab datawindow,But when
i try to use PB saveas function it is not capturing all the column values. So I
tried to generate crosstab datawindow first as html format and try to convert
Excel format through from PB code.

I manually tried this option it is working fine. First I generate the crosstab
datawindow as Html format then I open the html file and right click there is a
option for Export to Microsoft Excel. It is capturing all the column values as
per the Crosstab datawindow design.

I want to try this option through from PB code.

Thanks
Bojarajan

On 12 Jan 2009 13:02:33 -0800,
in sybase.public.powerbuilder.ole-ocx-activex

0 new messages