?
Solved

VB6 - Excel PrintPreview

Posted on 2006-06-28
2
Medium Priority
?
899 Views
Last Modified: 2008-01-09
Hi

I am using Visual Basic 6 SP6,  Windows XP Pro and Excel 97. I have a predefined workbook in which there is a predefined worksheet and predefined Chart.

I have bound Excel in my startup module so that is not a problem. The following is my code:

Option explicit

Dim wSheet as Excel.Worksheet
Dim wChart as Excel.Chart

Load Event

Set wBook = ObjExcel.WorkBooks.Open("WorkSheetName")
Set wSheet = ObjExcel.Sheets(1)
Set wChart = ObjExcel.Charts(1)

I now click a Command button which executes the following code:

ActiveWorkBook.Charts.Printout

The Chart prints to the printer without a problem but when I try and execute the following code:

ActiveWorkBook.Charts.PrintPreview Or
ActiveWorkBook.Charts.PrintOut  Preview:=True

The application just hangs. When I cancel Excel my error handler displays the following message:

-2147023170 Automation Error The Remote Procedure Call Failed.

Any idea what could be wrong ?.

 

0
Comment
Question by:Annin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 8

Accepted Solution

by:
kaliyugkaarjun earned 375 total points
ID: 17000117
0
 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 17000129
On link that gives code for print preview of selected sheets
http://www.ozgrid.com/forum/showthread.php?s=3ffce61601d3ca3a07dd23fe8d466547&t=38975
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question