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
Set xlWkBk = Nothing
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.