Excel Export Prompting to Overwrite.

C

Chuck

Hello,

I have a command button that I want to have export a
query to Excel. It exports a different query based on
the selections the user picks. I have it working except
it does not prompt the user if the want to overwrite the
file or not, it just does it automatically. I created a
macro to do the export. If I run the macro from the
database window it does prompt for an overwrite. If I
use the DoCmd.RunMacro command in VB it does not prompt
to overwrite. Is there a way to make the RunMacro
command prompt for an overwrite? Or is there a way to
make the OutputTo command prompt for overwrite?

Thanks,
Chuck
 
T

Turner

Try This:

if len(dir("C:\YourDir\YourFileName")) > 0 then
If msgbox("OverWrite File?",vbyesno) = vbyes then
DoOutput YourFileName
else
msgbox "File Not OverWritten"
endif
else
DoOutput YourFileName
endif

Dean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top