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

Application.OpenDoc with variable not working

Hi

I'm trying to open a set of documents via macro (vbscript) in a button, using a user selected value in a field as document path and name, but keeps giving me "Failed to open document", if I replace de variable for fixed text it works

Environment:

QV 10.0.9061.7 SR3 64bit

Windows 2008 R2 server standar 64 bit

The script:

sub Macro1

set doc1 = ActiveDocument

set SelectedValueInDocument = doc1.fields("xDocuments").GetSelectedValues

'Note: the button is active only if GetSelectedCount('xDocuments')=1

if SelectedValueInDocument.Count > 1 then

    msgbox "Warning: there is more than 1 value selected"

end if

vDoc = SelectedValueInDocument.Item(0).text

msgbox  vDoc   'here shows correct path and document name (the name has no spaces, backslash, comma, colon or semi colon)

set App = doc1.GetApplication

set newdoc = App.OpenDoc (vDoc,"","")   ''  <<== this gives error

'set newdoc = App.OpenDoc ("C:\QV\DESA\APPS\common\QVW\MyChileDocument[6-2].qvw","","")  '<- this works but need to change document  to match user selection

newdoc.Activate

 

end sub

  '

Any Ideas why get error with the variable?

Best regards

Walter

1 Solution

Accepted Solutions
Not applicable
Author

I found it.

I Had some characters along the way who apparently did not like. delete some "'- []" in the name and path and now it works.

View solution in original post

1 Reply
Not applicable
Author

I found it.

I Had some characters along the way who apparently did not like. delete some "'- []" in the name and path and now it works.