Solved

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

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

Technology Partners: 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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

736 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