Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
marksmunich
Creator III
Creator III

Macro Troubleshooting

Hello community,

I am running a macro in my qlikview document and i have a Trigger on a button.

I have the following code in the macro module:

This works fine when i click on the test in the edit module console, but it doesnt work when i click on the button, I have also made Setting in the document properties Macro override security and also in macro edit module I have set requested module securit to System Access and also current local security. Is there any mistake in this process. btw i got this code from the community. what is this SUB callexample after the function. Do i Need to replace it with my qvw document Name or just leave it as it is.

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

  objExcel.Worksheets(1).select()

  objExcel.Visible = True

  set CellMatrix = obj.GetCells2(0,0,w,h)

  column = 1

  for cc=0 to w-1

   objExcel.Cells(1,column).Value = CellMatrix(0)(cc).Text

   objExcel.Cells(1,column).EntireRow.Font.Bold = True

   column = column +1

  next

  c = 1

  r =2

  for RowIter=1 to h-1

    for ColIter=0 to w-1

      objExcel.Cells(r,c).Value = CellMatrix(RowIter)(ColIter).Text

      c = c +1

    next

   r = r+1

   c = 1

next

END FUNCTION

SUB CallExample

   ExcelExport( "CH06" )

END SUB

Thanks

Mark

1 Solution

Accepted Solutions
tresesco
MVP
MVP

In the trigger macro name, put the subroutine name  "CallExample" instead of the function name and try.

View solution in original post

17 Replies
rajeshvaswani77
Specialist III
Specialist III

Hi Marks,

Use a msgbox in code to print the values at various points in code.

Will help you debug.

syntax is

msgbox "hello world"

thanks,

Rajesh Vaswani

marksmunich
Creator III
Creator III
Author

Hi Rajesh,

this makes no difference. I can see the result when iam in the Macro edit module, when i hit test, Excel is generated, but when i Close this macros module and hit on the button in the layout document which has Trigger to run this macro, the Excel is not generated.

Even i see Helloword Msg box, when i test in the macro module.

thanks

Mark

rajeshvaswani77
Specialist III
Specialist III

Hi Mark,

In Macro module. can you make sure that

1) Requested module security is set to System Access

2)Current local security is set to Allow System Access.

thanks,

Rajesh Vaswani

jerrysvensson
Partner - Specialist II
Partner - Specialist II

MsgBox shouldn't make a difference, but by placing them in your code you can see where it fails.

rajeshvaswani77
Specialist III
Specialist III

Also in the QEMC


QlikView Servers, expand and click, Seucrity tab in the right pane "Allow unsafe macro execution on server" and "Allow macro execution on server" ticked) and in the Macro editor, (Ctrl + M, bottom left drop downs)

thanks,

Rajesh Vaswani

marksmunich
Creator III
Creator III
Author

Jerry Svensson  Ya I got the Point. since iam not much familiar with Macro Code,  it doesnt help me either.

Rajesh Vaswani :

i have both Settings in macro module enabled.

1) Requested module security is set to System Access

2)Current local security is set to Allow System Access

anyother changes ??

Still it is not working, when i hit ´button on frontend which runs this macro.

Thanks

Mark

rajeshvaswani77
Specialist III
Specialist III

If you made a server side change for,

QEMC


QlikView Servers, expand and click, Seucrity tab in the right pane "Allow unsafe macro execution on server" and "Allow macro execution on server" ticked) and in the Macro editor, (Ctrl + M, bottom left drop downs)

please restart the services.

thanks,

Rajesh Vaswani

marksmunich
Creator III
Creator III
Author

Even These Options have been enabled before this application is developed. More over  this has not been deployed. yet. i am just testing this on the develper tool.

Thanks

Mark

rajeshvaswani77
Specialist III
Specialist III

Is the call in trigger external run macro calling the macro? Comment out all code and just put a message box.

the macro function should be called by just the name in that box.

thanks,

Rajesh Vaswani