Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

marksmunich
Contributor II

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
MVP
MVP

Re: Macro Troubleshooting

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

17 Replies
rajeshvaswani77
Valued Contributor III

Re: Macro Troubleshooting

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
Contributor II

Re: Macro Troubleshooting

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
Valued Contributor III

Re: Macro Troubleshooting

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
Valued Contributor II

Re: Macro Troubleshooting

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

rajeshvaswani77
Valued Contributor III

Re: Macro Troubleshooting

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
Contributor II

Re: Macro Troubleshooting

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
Valued Contributor III

Re: Macro Troubleshooting

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
Contributor II

Re: Macro Troubleshooting

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
Valued Contributor III

Re: Macro Troubleshooting

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

Community Browser