Solved

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 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…

705 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

15 Experts available now in Live!

Get 1:1 Help Now