Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2007, 10:55 AM
Registered User
 
Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Why so?

With VB 2005, get into into the current, already open PowerPoint (Office 2003) presentation (and, for example get its name):

Dim ppapp As New PowerPoint.Application
MsgBox(ppapp.ActiveWindow.Caption)

It works. Then, why the same with Excel:

Dim xlapp As New Excel.Application
MsgBox(xlapp.ActiveWindow.Caption)

produces error "Object reference not set to an instance of an object"?
It bewilders me. How can I get into the Excel sheet that is already open?
 
Old October 18th, 2007, 03:05 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

“Why so?” is not much of a subject line. It is assumed from the fact that you are posting a question t all that you have a question...

I would think that the new application object has no active window, because no workbook has been opened.

Try stopping the code after the line Dim xlapp . . ., and examine that variable in the watch window to see if the object variable itself is not yet anything, or if it is the ActiveWindow property that is nothing yet.









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.