Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Danpil
Contributor
Contributor

VBScript. Rename expression Labels doesn't work.

Hi All,
The macro below renames expression Labels. The cycle matches the labels to the list.
Without this text: MsgBox( "Text" )
Renames only first Label from the cycle.
Together with this text it works out correctly with all Labels.
Should work with all Labels without displaying a message and the need to click "OK".
Can you please tell me what's my mistake? Or than replace MsgBox?

'-->
Sub Test1
set App = ActiveDocument.GetApplication
SET QVDoc = App.OpenDoc ("F:\Разработка\Чуваева\20395_Глоссарий\Учетная цена по компании (УЦК январь 2018). Движения.qvw","","")
ActiveDocument.Activate 'QVDoc.Activate '

'7. '======== Renames Labels ===================
SET Glos = QVDoc.GetSheetObject("Glos")
Gw = Glos.GetColumnCount
Gh = Glos.GetRowCount
set CellG = Glos.GetCells2(0,0,Gw,Gh)

QVDoc.Sheets(0).Activate

FOR GLi = 1 to Gh-1 'Перебор по строкам Глоссария от 0

For ColIter = 0 to Eval(CellG(GLi)(0).Text).GetProperties.Expressions.Count-1

MsgBox( "Text" )
'QVDoc.GetApplication.Sleep 1000 ' Doesn't work.
'ActiveDocument.GetApplication.Sleep 1000 ' Doesn't work.

IF (CellG(GLi)(4).Text + "|" + Eval(CellG(GLi)(0).Text).GetProperties.Expressions.Item(ColIter).Item(0).Data.ExpressionVisual.Label.v) = CellG(GLi)(2).Text THEN
set p = Eval(CellG(GLi)(0).Text).GetProperties
p.Expressions.Item(ColIter).Item(0).Data.ExpressionVisual.Label.v = CellG(GLi)(3).Text
Eval(CellG(GLi)(0).Text).SetProperties p
End If

Next
NEXT

msgbox("End.")
End Sub
'--<

1 Solution

Accepted Solutions
Frank_Hartmann
Master II
Master II

what happens if you call this function instead of sleep?

 

function dteWait
dteWait = DateAdd("s", 10, Now())
Do Until (Now() > dteWait)
Loop
end function

or maybe this statement:

ActiveDocument.GetApplication.WaitForIdle

 

View solution in original post

2 Replies
Frank_Hartmann
Master II
Master II

what happens if you call this function instead of sleep?

 

function dteWait
dteWait = DateAdd("s", 10, Now())
Do Until (Now() > dteWait)
Loop
end function

or maybe this statement:

ActiveDocument.GetApplication.WaitForIdle

 

Danpil
Contributor
Contributor
Author

Thank you very much!
ActiveDocument.GetApplication.WaitForIdle      worked!