Excel Export Prompting to Overwrite.

From: Turner (anonymous_at_discussions.microsoft.com)
Date: 05/05/04


Date: Wed, 5 May 2004 11:27:24 -0700

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

>-----Original Message-----
>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
>.
>