Forum Discussion

ArmandsBruns's avatar
ArmandsBruns
Frequent Contributor
13 years ago

If I want to run the project again and again to "Save As" EXCEL file

Hi,



If I want to run the project again and again to "Save As" EXCEL file:

MSExcel.ActiveWorkbook.SaveAs "*.xls"



Then it shows the unexpected window (attach: "Excel_already_exists")

I need to press "YES"



I create "GeneralEvents_OnUnexpectedWindow" and attach in "GeneralEvents" (attach: "GeneralEvents_OnUnexpectedWindow" ),

but it doesnt't work.

Are there any ideas how can press "YES"



Armands
  • ArmandsBruns's avatar
    ArmandsBruns
    Frequent Contributor
    Hi Jay,

    Thanks for your response






    my solution:

    --------------------------------------------------

    Dim MSExxcel

    Set MSExcel = Sys.OleObject("Excel.Application")

    MSExcel.Visible = True

      If Utilities.FileExists("D:\LTT_Rezultati_IE.xls") Then  

        MSExcel.ActiveWorkbook.Save ' Save

        MSExcel.Quit()

      Else

        MSExcel.ActiveWorkbook.SaveAs "D:\LTT_Rezultati_IE.xls" ' Save As

        MSExcel.Quit()

      End If

    --------------------------------------------------------

    Årmands