Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Excel Macro - delete sheets

Hi guys. I've written a macro to export data to an excel template and delete certain tabs. However; when i do this is get "Data may exist in the sheet(s) selected for deletion. To permanently delete the data, press Delete.". Can anyone suggest a way to suppress this message and just proceed with the delete?

The code is here

Sub export_report

set XLApp = CreateObject("Excel.Application")

XLApp.Visible = true

set XLDOC = XLApp.Workbooks.Open ("R:\Team\Business Solutions\PDW\Tasks\Qlikview data testing\Data feedback 1.xlsx")

'Counts rows in the table

set v = ActiveDocument.GetVariable("CountRowsTable")

getVariable1 = v.GetContent.String

ActiveDocument.Fields("Missing tax amount").Select "True"

ActiveDocument.GetSheetObject("CH11").CopyTableToClipboard true

'The below will check if there's any content in the table and if there isn't, print nothing

ActiveDocument.Variables("CountRowsTable").SetContent chart.GetNoOfRows, true

set v = ActiveDocument.GetVariable("CountRowsTable")

getVariable = v.GetContent.String

'Auto fit

if getVariable <> getVariable1 then

  set XLSheet = XLDOC.Worksheets("Missing tax Amount")

  XLSheet.Paste XLSheet.Range("A3")

  XLSheet.Range("a3:p3000").ColumnWidth = 105.00

  XLSheet.Range("a3:p3000").EntireColumn.AutoFit

  XLSheet.Rows("1:3000").EntireRow.AutoFit

End if

'If there's no data to export; delete the tab

if getVariable = getVariable1 then

  XLDOC.Sheets("Missing tax amount").Delete

End if

ActiveDocument.Fields("Missing tax amount").Clear

End sub

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

XLApp.DisplayAlerts = False

View solution in original post

1 Reply
m_woolf
Master II
Master II

XLApp.DisplayAlerts = False