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: 
Not applicable

JScript

Hi there,

I'm looking for a working example of JScript macro's in a qvw .

The absence of any reference to JScript in manuals or fora makes me wonder if it's being used at all..

But isn't JScript superior to VBScript? (more functionallity, harder, better, faster, stronger..;-)

With kind regards,

B

12 Replies
Not applicable
Author

But that is its biggest weakness...... most (all?) QV developers use VBS Big Smile

Not applicable
Author

You can find a JavaScript section in the API guide.

I'm one of those developers that likes to stick to VB. Since we are somewhat limited by QlikView macro capabilities, I'm not sure that one has a definite advantage over the other. If JavaScript was faster and offered additional functionality that I couldn't get with VB, I'd be switching.

My only complaint about JavaScript is that I don't like typing the { brackets. Set analysis uses enough of those already! Wink

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Agree with both replies. Everybody is using VBScript. Even the Automation Reference is written entirely for VBScript. So, my recommendation - go with the flow 🙂 It always pays in the long run.

Another recommendation - use sparingly!Macros are a lot of fun, but also a lot of trouble. In my history of 4 major release upgrades (ever since QlikView 5), the only thing that I had to redo every single time is macros, because the API set is changing from one release to another.

Oleg

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I used Jscript in one of my frst applications and have regretted it ever since. You can't mix Jscript and VBS in the same document. The API examples, the code you get on this forum, from other examples -- it's all VBS and you have to go through a conversion effort to reuse it as Jscript. Ugh.

It's true that Jscript is much easier in some ways -- for example, array handling. But I've found that I use very few macros and they are quite simple so the language is no big deal.

-Rob

Not applicable
Author

Is it a mistake to say that Ajax does not support properly VBScript ?

Is there any function that works in JavaScript and not in VBScript ?

Today I have a problem with a macro that works perfectly using IE Plugin and not with AJAX.

That macro just does a copytabletoclipboard and tries to copy it in an Excel spreadsheet.

Is it a VBScript Issue and if yes , does that mean I will need to use Javascript to do that function ?

Thanks

Philippe

Not applicable
Author

Philippe,

Avez-vous trouvé une réponse à votre question? Je cherche à faire la même chose.

Kevin

Not applicable
Author

J'ai trouvé une solution qui ne passe pas par le copyClipboard.

Philippe

Not applicable
Author

Ce que je veux faire c'est copier des données de Qlikview (version ajax) dans un fichier Excel. Je sais que les Qlikview macros sont très limités dans ajax. J'ai ajouté du script au HTML mais cela ne me donne pas accès aux objets Qlikview. L'option Send to Excel ouvre un spreadsheet vierge avec un nom tiré au hasard. Je veux coller l'information dans le template que j'ai créé. Comment as-tu fait?

Kevin

Not applicable
Author

Voici l'exemple de macro utilisée.

Sub Create_Excel

set XLApp = CreateObject("Excel.Application") ' Open the Excel Application
XLApp.Visible = false
On Error Resume Next 'Make the Excel application visible or not (Test Purpose)
set XLDoc = XLApp.Workbooks.Add 'Create a Workbook
If (Err.Number > 0) Then
set v = ActiveDocument.Variables("DebugVariable")
v.SetContent Err.Number , 123
exit sub
End If


XLApp.Worksheets.Add().Name = 'TEST' ' Addition of sheets
set table = ActiveDocument.GetSheetObject( "CH62" )
for RowIter = 0 to table.GetRowCount-1
for ColIter =0 to table.GetColumnCount-1
set cell = table.GetCell(RowIter,ColIter)
XLApp.Worksheets("Overbook-Underbook (Protected)").Cells(RowIter +1, ColIter +1).Value = cell.Text
next
next
XLApp.Worksheets(1).Cells.EntireColumn.AutoFit 'Automatic Fit
XLApp.Worksheets(1).Cells.EntireRow.AutoFit
XLApp.Worksheets(1).cells.WrapText = false 'Disable Wraping text

SaveFile=StrFileName & ";56"
On error resume next
If XLApp.Version < 12 then ' Excel Version Test
xlDoc.SaveAs StrFileName
Else
xlDoc.SaveAs StrFileName , 56
End if
If Err.Number <> 0 then
GetEnvErr="ERROR: Unable to save " & StrFileName
Err.Clear
xlApp.Quit
Exit sub
End If
xlDoc.Close True
xlApp.Close 'closes the workbook. "True" means that it saves modifications
xlApp.Quit 'closes excel. it's quite important