Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
SteveZheng
New Contributor

Qlikview Macro call Excel macro doesn't work in Wins10

Hello,

I used to use a qlikview macro to call an excel macro which will perform a certain task in excel in win 7. It worked fine. However since I switched to Win 10, it didn't work any more. The Qlik macro will stop at "oSH.Application.Run "GetSheetsAR" and error message said : "Cannot run the macro 'GetSheetsAR'. The macro may not be available in this workbook or all macros may be disabled."

I went to the excel trusted center and enable the macro settings, but it still didn't work. I also tried add trusted locations in excel, still not work. 

I wonder if anyone has the same issue and is there any solution here? 

(the excel macro AR.xlsm works fine if I manually run it). 

Thanks a lot,

Steve

This is Qlikview macro below:

Sub AR
Set oXL=CreateObject("Excel.Application")
f_name="C:\Users\Public\Documents\NPrinting\Output_AR\MonthlyReconcile\AR.xlsm"
Set oWB=oXL.Workbooks.Open(f_name)
Set oSH=oWB.Worksheets.Item(1)
oSH.Application.Run "GetSheetsAR"
'oWB.Save
'oWB.Close
Set oSH=nothing
Set oWB=nothing
Set oXL=nothing
End Sub

11 Replies
Highlighted
mwoolf
Honored Contributor II

Re: Qlikview Macro call Excel macro doesn't work in Wins10

This code to trigger an Excel macro seems to work fine in W10:

strMacro = "'" & XLWorkbook.Name & "'!" & "MacroName"
xlApp.Run(strMacro)

Highlighted
SteveZheng
New Contributor

Re: Qlikview Macro call Excel macro doesn't work in Wins10

Hi, 

thanks for your reply! Is this written in Qlikview? May I get the context of the two lines? 

 

Thanks,
Steve

Highlighted
mwoolf
Honored Contributor II

Re: Qlikview Macro call Excel macro doesn't work in Wins10

I don't know what you mean by "the context of the two lines"

xlApp is the Excel application object
XLWorkbook is the workbook object

 

Highlighted
SteveZheng
New Contributor

Re: Qlikview Macro call Excel macro doesn't work in Wins10

Hi,

the macro I need is supposed to be written in Qlikview not in Excel. Macro in Qlikview call a macro in Excel. 

 

Steve

Highlighted
mwoolf
Honored Contributor II

Re: Qlikview Macro call Excel macro doesn't work in Wins10

This is vbscript code from a QlikView application.

Highlighted
SteveZheng
New Contributor

Re: Qlikview Macro call Excel macro doesn't work in Wins10

I see. May I know how did you define the xlApp and XlWorkbook?
Highlighted
mwoolf
Honored Contributor II

Re: Qlikview Macro call Excel macro doesn't work in Wins10

Set XLApp = CreateObject("Excel.Application")
Set XLWorkbook = XLApp.Workbooks.Open("FilePathHere" & "\" & "CreateChart Test.xltm",3)

Highlighted
SteveZheng
New Contributor

Re: Qlikview Macro call Excel macro doesn't work in Wins10

Hi, 

I changed my script as suggested as below. But it still show me the same error message: "Can't run the macro"****", the macro may not be available in this workbook or all macros may be disabled."

I have go to excel and enable all macro related options. 

Steve

 

Sub AR
Set xlApp=CreateObject("Excel.Application")
Set XLWorkbook = XLApp.Workbooks.Open("C:\Users\Public\Documents\NPrinting\Output_AR\MonthlyReconcile" & "\" & "AR.xlsm",3)
strMacro = "'" & XLWorkbook.Name & "'!" & "GetSheetsAR"
xlApp.Run(strMacro)

Set oSH=nothing
Set oWB=nothing
Set oXL=nothing
End Sub

Highlighted
mwoolf
Honored Contributor II

Re: Qlikview Macro call Excel macro doesn't work in Wins10

I don't think your problem is with the code.

I created a test qvw on a W10 machine with your macro script. Then I created a test excel workbook named "AR" with a macro named "GetSheetsAR". When I triggered the macro script in QlikView, it opened the Excel workbook and ran the macro.