I am using VBScript to allow a program to pass data to Excel. Once the data
is passed, the program re-opens the workbook which it has passed the data to
in order to analyse.

At certain stages during the running of the script, the following 'Server
Busy' message appears:

"This action cannot be performed because the other program is busy. Choose
'switch to' to activate the program and correct the program."

I have been advised to use the 'objExcel.DisplayAlerts = False' instruction
but this appears not to be working.

Why is this happening and is there a way to avoid it? It happens at some
points at certain occasions, and at other points every time the program is
run.


--
Charles Dean

Re: the 'switch to' message by Gilliland,

Gilliland,
Fri Aug 31 06:52:34 PDT 2007

Is it possible to see your code?

Thanks,
Gill


On 8/30/07 8:14 PM, in article
C1E10B0E-D95A-4F59-9464-FEFB05614CC4@microsoft.com, "CCDEAN100"
<CCDEAN100@discussions.microsoft.com> wrote:

>
> I am using VBScript to allow a program to pass data to Excel. Once the data
> is passed, the program re-opens the workbook which it has passed the data to
> in order to analyse.
>
> At certain stages during the running of the script, the following 'Server
> Busy' message appears:
>
> "This action cannot be performed because the other program is busy. Choose
> 'switch to' to activate the program and correct the program."
>
> I have been advised to use the 'objExcel.DisplayAlerts = False' instruction
> but this appears not to be working.
>
> Why is this happening and is there a way to avoid it? It happens at some
> points at certain occasions, and at other points every time the program is
> run.
>


Re: the 'switch to' message by CCDEAN100

CCDEAN100
Fri Aug 31 11:46:02 PDT 2007


THERE ARE THREE SCRIPTS (THOUGH IN THE BUILT-IN SCRIPT EDITOR I'M USING THEY
ARE CALLED 'RECIPES'). THE FIRST ONE IS RUN,
COLLECTS DATA AND AND PASSES IT TO AN EXCEL WORKBOOK TEMPLATE (PRE-FORMATTED).

THE FIRST SCRIPT CLOSES ITSELF AND ACTIVATES THE SECOND ONE. THIS SECOND
SCRIPT CALLS THE SAME INSTANCE OF THE WORKBOOK AS
THAT CREATED BY THE FIRST SCRIPT, COLLECTS DATA AND PASSES IT TO THE WORKBOOK.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

FIRST SCRIPT EXCEL COMMANDS -

Set objExcel = CreateObject("Excel.Application")
Set workbook = objExcel.Workbooks.Open("C:\Program
Files\SHAREDDATA\Recipes\REQUIRED FILES\EXCEL.TEMPLATE.xls")
objExcel.DisplayAlerts = False

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

SECOND SCRIPT EXCEL COMMANDS -

Set objExcel = GetObject( ,"Excel.Application")
Set workbook = objExcel.ActiveWorkbook
Set objSheet = workbook.Sheets(2)
Set objSheet2 = workbook.Sheets(3)
objExcel.DisplayAlerts = False

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

BOTH BLOCKS OF CODE ABOVE ARE FOLLOWED WITH THE CODE BELOW TO PASS DATA FROM
THE ARRAY TO EXCEL:

ARRcol = 0

For EXCcol = 1 To BACKSCAN_NUM

ARRrow = 0
EXCrow = 6

Do
objExcel.Cells(EXCrow, EXCcol).Value = MASSVALUES(ARRrow,ARRcol)
EXCrow = EXCrow + 1
ARRrow = ARRrow + 1

Loop Until ARRrow = REDIMrow

ARRcol = ARRcol + 1

Next

THE SECOND SCRIPT RUNS THE FOLLOWING CODE TO SAVE THE DATA AND STARTS A
THIRD SCRIPT TO RUN THE DATA ANALYSIS FEATURE:


intReturn_5 = MsgBox ("Do you want to save the data?", 4 + 32)

If intReturn_5 = 6 Then
intReturn_9 = InputBox ("Please enter the name of the file for saving")
workbook.SaveAs intReturn_9
ElseIf intReturn_5 = 7 Then
intReturn_8 = MsgBox ("Are you sure you want to discard the recently
acquired data?", 4 + 16)
End If


intReturn_7 = MsgBox ("Do you want to analyse the data?", 4 + 32)

If intReturn_7 = 6 Then
Recipe.StartRecipe("CD.RECIPE.DATANALYSIS")
objExcel.Quit
Recipe.Abort
ElseIf intReturn_7 = 7 Then
objExcel.Quit
Recipe.Abort
End If

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

THE THIRD SCRIPT STARTS WITH THE FOLLOWING IN ORDER TO ALLOW THE USER TO
OPEN THE SPECIFIED EXCEL FILE THEY HAVE JUST SAVED:

msoFileDialogOpen = 1

Set Excel = CreateObject("Excel.Application")
Excel.Visible = False
Excel.DisplayAlerts = False

Set OpenFileDlg = Excel.FileDialog _
(msoFileDialogOpen)

OpenFileDlg.AllowMultiSelect = False
OpenFileDlg.InitialFileName = "C:\*.xls"
OpenFileDlg.Filters.Clear
OpenFileDlg.Filters.Add "Excel files", "*.xls"
OpenFileDlg.Show

If OpenFileDlg.SelectedItems.Count > 0 Then
Set WBook = Excel.Workbooks.Open _
(OpenFileDlg.SelectedItems(1))
Excel.Visible = False

Else
End If

Set WBook = WBook.Sheets ("LS DATA")
Excel.Visible = False


'get data from the first sheet
var1 = WBook.Cells(3,3)
var2 = WBook.Cells(4,3)
var3 = WBook.Cells(5,3)

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

VARIABLES 'var1', 'var2' and 'var3' ARE THEN USED TO PERFORM AN ANALYSIS
FUNCTION USING A SERIES OF 'IF' STATEMENTS. THE RESULT IS OUTPUTTED TO THE
USER VIA A MESSAGE BOX.

Sometimes the "server busy" message appears at the start of script one, and
always appears in between the code for the input box
requesting a name to save the data under, and the message box whether they
wish to analyse the data. It also always appears during
the third script straight after the user has chosen the file containg the
data they wish to analyse.

Hope this is enough information (I have missed out some of the code to save
space) Can you help?