Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
qlikmeplease
Contributor III

Overwriting Existing File on Export Macro

Hi,

Currently i have the below script.  All it does, is exports a table from Qlikview.  However, i need Qlikview to REPLACE the existing file without a prompt from Excel.

XLDoc.DisplayAlerts = False does not work , because although it doesn't display it, it ends up not overwriting the file autmatically.

Please assist.

sub Export

set XLApp = CreateObject("Excel.Application")

XLApp.Visible = True 'you can make it false, if you want to make it in the background

set XLDoc = XLApp.Workbooks.Add

XLDoc.Sheets(1).name = "Export"

set XLSheet = XLDoc.Worksheets(1)

set MyTable = ActiveDocument.GetSheetObject("TB01") 'Change TB01 to the object you want to export to Excel (Object Properties > General tab > far right)

set XLSheet = XLDoc.Worksheets(1) 'Select sheet where data should be pasted

Mytable.CopyTableToClipboard true 'Copy data to Clipboard

XLSheet.Paste XLSheet.Range("A1") 'Paste data starting at A1

     XLDoc.DisplayAlerts = False

XLDoc.SaveAs "...............\Sequence.xlsx"

XLDoc.DisplayAlerts = True

End Sub

2 Replies
MVP & Luminary
MVP & Luminary

Re: Overwriting Existing File on Export Macro

Try this:

...

XLApp.DisplayAlerts = False

XLDoc.SaveAs "Path\Sequence.xlsx"

XLApp.DisplayAlerts = True

...

- Marcus

qlikmeplease
Contributor III

Re: Overwriting Existing File on Export Macro

Thanks, I tried this before, seems I put it in the wrong place.  this worked perfect thanks.

Regards,