Solved

VB6 - Excel PrintPreview

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

688 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