A
Andy
This is a bit complicated and the problem is in two parts!
I have an Access database from which I have created a
procedure that, in theory, iterates through a number of
recordsets and on each iteration dumps the data to an
Excel object that it creates and then runs an Excel macro
to perform various formatting and calculation tasks. The
last thing the Excel macro does is attempt to save the new
workbook with a given name. The workbook is then closed
and the Access procedure continues with the next recordset.
If the name already exists the standard 'File name exists,
do you want to replace it?' type dialog box appears with
the Yes, No and Cancel buttons. If the user clicks Yes
then all is well and the file is overwritten. However...
Problem 1
If the user clicks No or Cancel a '1004' error is thrown,
which I can trap but I don't know how to identify which
button was pressed.
Problem 2
Assuming I can identify the button that was pressed, I
would like to be able to let Access know that the Cancel
button was pressed so that it can exit the Access
procedure. Incidentally, if No is pressed then I will
make the Save As dialog box appear but I do know how to do
that!
I have an Access database from which I have created a
procedure that, in theory, iterates through a number of
recordsets and on each iteration dumps the data to an
Excel object that it creates and then runs an Excel macro
to perform various formatting and calculation tasks. The
last thing the Excel macro does is attempt to save the new
workbook with a given name. The workbook is then closed
and the Access procedure continues with the next recordset.
If the name already exists the standard 'File name exists,
do you want to replace it?' type dialog box appears with
the Yes, No and Cancel buttons. If the user clicks Yes
then all is well and the file is overwritten. However...
Problem 1
If the user clicks No or Cancel a '1004' error is thrown,
which I can trap but I don't know how to identify which
button was pressed.
Problem 2
Assuming I can identify the button that was pressed, I
would like to be able to let Access know that the Cancel
button was pressed so that it can exit the Access
procedure. Incidentally, if No is pressed then I will
make the Save As dialog box appear but I do know how to do
that!