Solved

Prview Worksheet using VB 6... Component Request Pending...

Posted on 2004-08-09
1
406 Views
Last Modified: 2008-02-01
I have this code to preview worksheet 'Sheet1' (code in VB 6 environment):

Dim xlApp As New Excel.Application
Dim xlWkBk As Excel.Workbook
Dim xlWkSht As Excel.Worksheet

Set xlWkBk = xlApp.Workbooks.Open("C:\MyFolder\Test.xls")
Set xlWkSht = xlWkBk.Worksheets("Sheet1")
xlWkSht.PrintPreview     <--- error here

Set xlWkSht = Nothing
xlWkBk.Close
Set xlWkBk = Nothing
xlApp.Quit
Set xlApp = Nothing

The error says:
Component Request Pending.  This action cannot be completed because the other application is busy.  Choose 'Switch To' to activate the busy application and correct the problem.
--------------
'Switch To', temporarily removes the error message and show (switches to) vb 6 code window.  Upon clicking on this code window, the error message reappears.  I have to use End Task to end this cycle.
--------
Q1. What component I need to add in reference section to solve this problem?  (I had a previous error on "Dim xlApp As New Excel.Application" and had to check "Microsoft Excel" in component reference section to deal with it.)

Q2. I was expectiong Excel to open after: Set xlWkBk = xlApp.Workbooks.Open("C:\MyFolder\Test.xls")      It maybe opens hidded and that is why 'Swich To' doesn't work?  Not sure about it.  Besides, I wouldn't know what to fix there either.

Do you have some direction for me to take?  I am lost.

Mike
0
Comment
Question by:Mike Eghtebas
1 Comment
 
LVL 22

Accepted Solution

by:
DarkoLord earned 250 total points
ID: 11754518
Put

xlApp.Visible = True

before xlWkSht.PrintPreview


Darko
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

830 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