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

Ole object (how to open a file in excel)

1,161 views
Skip to first unread message

cch

unread,
Dec 27, 2008, 9:34:29 PM12/27/08
to
I am using PB11.2 build 8669. After instanciate excel via ole control how do
I open a particular file?

myoleobject = CREATE oleobject
rc = myoleobject.ConnectToNewObject ("Excel.Application")
If rc <> 0 Then
MessageBox ( "Error", String ( rc ) )
Return
End If
myoleobject.Application.Visible = TRUE

Here I would like to open a particular file, does anybody knows what is the
command?

Regards,

CCH


Bruce Armstrong [TeamSybase]

unread,
Dec 28, 2008, 12:10:55 AM12/28/08
to

You can figure out the commands to use by opening up the VBA editor
within the target office product (Alt-F11, F2). For most of the
products, you can also record a macro in the product and then look at
that in the editor to see the commands.

On 27 Dec 2008 18:34:29 -0800, "cch" <ccha...@arazozabrothers.com>
wrote:

-----------------------------------

My Web 2.0 Stuff

Blog: http://bruce.pbdjmagazine.com/
Facebook: http://www.facebook.com/people/Bruce-Armstrong/1600223798
Fotki: http://public.fotki.com/brucearmstrong/
LinkedIn: http://www.linkedin.com/in/bruceaarmstrong
Twitter: http://twitter.com/bruce_armstrong
YouTube: http://www.youtube.com/user/brucearmstrong

Wheeley

unread,
Dec 28, 2008, 1:06:27 AM12/28/08
to
On 27 Dec 2008 18:34:29 -0800, "cch" <ccha...@arazozabrothers.com>
wrote:

The easiest way to find this information is to record a macro as you
perform a file open. You will of course want to eventually do more
than just open the file. But since you asked:

myoleobject.Workbooks.Open ("<filename with path>")

Also, please be aware that there currently is no support for Office
2007 in any vesion of Powerbuilder. And I had better correct some
terminology misunderstanding of the controls before you get too deep.
The code above does NOT use an OLEControl. You are using an OLEObject.
There is a big difference in them. Here are some:

1. Office 2007 does NOT work with an OLEControl but does with
OLEObjects.
2. OLEControls allow inplace editing but an oleoject does not.
3. OLEControls use file extensions to figure out the ole application
to open. This is the crux of the problem with Office 2007.
Powerbuilder has no knowledge of the new filetypes.

So if you just want to perform remote control of Excel,then OLEObjects
are the best way to go. Lastly, please read the online help. The have
ome usefull information there alo.

Wheeley

P.S.
OLEOjects work fine with Excel 2007. So if you need Office 2007
support, you must use them.

Bruce Armstrong [TeamSybase]

unread,
Dec 28, 2008, 9:50:38 AM12/28/08
to

The part about Office 2007 support doesn't make any sense.
PowerBuilder doesn't have any control over that. If your operating
system (not PowerBuilder) isn't making the relationship between the
file extensions and the OLE control, it's a configuration issue with
your computer, not PowerBuilder.

cch

unread,
Dec 29, 2008, 9:42:12 AM12/29/08
to
It work perfect. Thank you very much all. Have a late very happy Merry
Christmas and very prosperous new Year.

"Bruce Armstrong [TeamSybase]" <NOCANSPAM_br...@teamsybase.com>
wrote in message news:kf4fl4l613k57840c...@4ax.com...

0 new messages