Solved

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

Posted on 2004-08-09
1
416 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

689 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