Solved

VB6 - Excel PrintPreview

Posted on 2006-06-28
2
793 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
  • 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now