Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]() "Bill Manville" wrote in message ... Bob Mignault wrote: (Note: Just before End Sub, if I add: xlApp.WindowState = xlMinimized I get a run-time error 1004: Unable to set WindowState property of the Application class.) Do you have a reference to the Excel object library? If not, xlMinimized will not be defined and, if you don't have Option Explicit at the top of your module (assuming that applies in VB as it does in VBA) you will have an implicitly defined variable whose value is Empty. This will give error 1004. I thought my problems were solved, until I tried the following command button event: Private Sub cmdOK_Click() Dim xlApp As Object Dim xlBook as Object Set xlApp = CreateObject("Excel.Application") xlApp.Windows("FileA.xls").Activate .... End Sub If that is the extent of your code then I am not surprised that the error occurs since you have created a new instance of Excel which doesn't have FileA.xls open in it. If you want to reference the previously created instance of Excel you should make xlApp a module-level variable (declared before all the Subs in the module) and remove the Dim statements from each of the Sub procedures. Bill Manville MVP - Microsoft Excel, Oxford, England No email replies please - respond to newsgroup Bill, I changed the coding as you suggested above, and everything now works fine. I don't know why my original code works on one computer, and not on the other. but I can live live with that! Many thanks for your help and patience. Regards, Bob Mignault |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|