Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi QV ers,
Could anyone help me with this macros:
I'm having error on this line : if v = "Alan" then ???? :Object doesn't support this property or method
sub setUser
set v = ActiveDocument.Variables("vUser")
msgbox(v.GetContent.String)
if v = "Alan" then
msgbox("ti si bace")
else
msgbox("tc ne 6te")
end if
end sub
Actually this works for me :
sub setUser
set v = ActiveDocument.Variables("vUser")
if v.GetContent.String = "Ivan" then
ActiveDocument.PlaySound "C:\Windows\Media\ding.wav"
else ActiveDocument.PlaySound "C:\Windows\Media\tada.wav"
end if
end sub
I believe this is what you need:
set v = ActiveDocument.Variables("vUser").GetRawContent
With your code, I believe v was the variable object, not the text contents of the variable.
It gives me Object required: '[string: "=USER_NICK"]' ???
So I have a variable vUser in QV
This variable is equal to who is the user from section access.
So I need to check who is the user (in the macro module) and than play sounds according to who is the user!
Thanks in advance!
I'm not sure what's wrong with yours, but here is working macro code from one of my applications that both checks and sets a variable's value.
set chartVariable = ActiveDocument.GetVariable("vDynamicChart")
chartID = chartVariable.GetRawContent
if chartID > "" then 'if there's already a dynamic chart
ActiveDocument.GetSheetObject(chartID).Close 'remove the old dynamic chart
chartVariable.SetContent "",false 'blank out the variable
end if
Thanks for the fast response but I'm still having problems
the vUser in QV =USER_NICK (USER_NICK - from section access)
use macro:
sub setUser
set MacroUser = ActiveDocument.GetVariable("vUser")
check = MacroUser.GetRawContent
if check = "Willy" then
ActiveDocument.PlaySound "D:\PROJECTS\ADAC\nostart.wav"
end if
end sub
and it is called: ready
but the user is Willy and the if statement says that if check <> "Willy" then ?????
What does a msgbox(check) tell you is in the field?
shittt : gives me "=USER_NICK"
How to make it work correctly ?
Tnx.
I would assume you need to check the value in the format it's actually in (=USER_XXXX), and not the format you thought it was in (Xxxx).
sub setUser
set MacroUser = ActiveDocument.GetVariable("vUser")
check = MacroUser.GetRawContent
if check = "=USER_WILLY" then
ActiveDocument.PlaySound "D:\PROJECTS\ADAC\nostart.wav"
end if
end sub
Actually this works for me :
sub setUser
set v = ActiveDocument.Variables("vUser")
if v.GetContent.String = "Ivan" then
ActiveDocument.PlaySound "C:\Windows\Media\ding.wav"
else ActiveDocument.PlaySound "C:\Windows\Media\tada.wav"
end if
end sub