Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

About Saving the created excel file in a specified path from macro

Hi,

How to save the created excel file in a specified path from macro for exporting the data object of a qlikview file.............

If u know the process Reply me,,,,,,

Waiting for ur replies

With Regards........

1 Reply
Not applicable
Author

Hi

Here is a macro that copy 2 table to 2 different sheet in excel.

Hope this help.

Regards

Anders

Sub SaveToExcel

NewFileName = "\\Sthnt004\Groups\Import\V1-R1-S1\Volume Planning\Qlikview\CarsInStock.xlsx"

set obj = ActiveDocument.GetSheetObject("CH18")
set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
set XLDoc = XLApp.Workbooks.Add
set rngStart = XLDoc.Sheets(1).Range("A1")
set XLSheet = XLDoc.Worksheets("Sheet1")
set XLSheet2 = XLDoc.Worksheets("Sheet2")
Const xlCenter = -4108

obj.CopyTableToClipboard true
XLDoc.Sheets("Sheet1").Paste()
XLDoc.WorkSheets("Sheet1").Cells.select
XLDoc.WorkSheets("Sheet1").Cells.EntireRow.RowHeight = 12.75
XLDoc.WorkSheets("Sheet1").Cells.EntireColumn.AutoFit

set Selection = XLSheet.Columns("A:H")
With Selection
.VerticalAlignment = xlCenter
.Borders.ColorIndex = 0 'black border
End With
XLSheet.Name = "Stock list summary"

' Next sheet
set obj = ActiveDocument.GetSheetObject("CH17")
set XLSheet = XLDoc.Worksheets("Sheet2")

obj.CopyTableToClipboard true
XLSheet2.activate
XLSheet2.Paste()
XLSheet2.Cells.select
XLSheet2.Cells.EntireRow.RowHeight = 12.75
XLSheet2.Cells.EntireColumn.AutoFit


set Selection = XLSheet2.Columns("A:H")
With Selection
.VerticalAlignment = xlCenter
.Borders.ColorIndex = 0 'black border
End With

XLSheet2.Name = "Stock list with options"

XLDoc.SaveAs NewFileName

XLApp.Quit

end sub