Solved

VB6 - Excel PrintPreview

Posted on 2006-06-28
2
852 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 125 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

697 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