Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all!!
I'm not familiar with macros at all! (unfortunatlly, not even the basics..)
I need a button that will export a table to excel. The table is stored in a container (if it is possible to the macro to recognaize which table is activated and should be exported, else the table will stand alone).
In addition to the export, I need the excel to be saved in a specific folder (NOT just opend).
And last, I want that only authorized users will be able to activate the button, OR that only authorized users will be able to export ALL fileds, and others will be able to export just specific fields.
I attached a QV where I tried to export a table wuth a macro (button) but somehow I couldn't make it to work.
Any help is welcomed!!
Thank you in advance.
sub ExportQcRegToExcel(QcRegressionExcelFilePath)
'check if the excel file already exists or not
'if not exists then create a new one otherwise edit the existing one
' Starts Excel
set XLApp = CreateObject("Excel.Application")
' Makes it run in background
XLApp.Visible = false
XLApp.DisplayAlerts = false
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(QcRegressionExcelFilePath)) Then
Set XLDoc = XLApp.Workbooks.Open (QcRegressionExcelFilePath)
Else
set XLDoc = XLApp.Workbooks.Add()
' Save the excel-file with the dynamic path and filename
XLDoc.SaveAs QcRegressionExcelFilePath
XLDoc.Sheets.Clear()
XLDoc.Sheets.Add()
XLDoc.Sheets(1).Name = "sheet_name"
End If
ActiveDocument.GetSheetObject("your_chart_id").CopyTableToClipboard true
XLDoc.Sheets("DevGroup").Paste()
XLDoc.Sheets("DevGroup").Rows("1:3000").EntireRow.AutoFit
' Save the excel-file with the dynamic path and filename
XLDoc.SaveAs QcRegressionExcelFilePath
' Exits the current running Excel
XLApp.Quit
end sub
Hi Ali and Thank you for your help!
As I mentioned before, I have no prior knowledge in macros... and I couldn't make it work with the script u sent.
can you pls try to upload an example?
We can create one button(Action Export to excel)->in layout we can give condition as OSUSER(NTNAME_1,NTNAME_2).
So that only give users can see button in dashboard.
check attached file
go to sheet 3 and click on the blue button
it exports the pivot table to an excel file near your qvw file
I don't know why, but when I click the button it opens the window "edit module" instead of exporting to excel
do you have write privilege to write the excel in the folder where your qvw exists?
Hagit,
Follow below:
Sub ExportExcel1
vFile = ActiveDocument.Variables("vInput1").GetContent.String
'XLDoc.SaveAs "c:\Qlikview\Claro"& vFile &".xls"
set obj = ActiveDocument.GetSheetObject("Your_object ID")
obj.ExportEx "\Path where you want to export this file"& vFile &".xls",5
End sub
OR
FUNCTION ExcelExport(objID)
set obj = ActiveDocument.GetSheetObject( objID )
w = obj.GetColumnCount
if obj.GetRowCount>1001 then
h=1000
else h=obj.GetRowCount
end if
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add
Thanks,
AS
I'm an administrator, So shoul'd have promission.
see attached
I read the error message
is Microsoft office installed on the machine you are working on?