?
Solved

VB6 - Excel PrintPreview

Posted on 2006-06-28
2
Medium Priority
?
938 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
Suggested Courses

650 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