Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Error in macro


sub StocksActivate
set f=ActiveDocument.Fields("inv")
set sv=f.GetSelectedValues
f.Select "(25|30|43)"
end sub

sub StocksDeactivate
set f=ActiveDocument.Fields("inv")
f.SelectValues sv
end sub


I create two subs for Page Triggers (first to Activate, second to Deactivate trigger). Main idea was to store current selection before activating page to sv variable, and restore it after deactivation. In sub Deactivate a get an error - "Type mismatch: 'f.SelectValues'"

Any ideas?

3 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Is sv declared as a global VB variable? From what you posted, it will be set in StocksActivate but not available to StocksDeactivate.

Anonymous
Not applicable
Author

You can add the following code to your macro to access the content of a variable in the qv document.



rem ** Get setting of variable **
set vT = ActiveDocument.GetVariable("vTest")
rem ** Get value of variable **
SelValue = vT.GetContent.String
rem ** Select data **
ActiveDocument.Fields("inv").Select SelValue




Not applicable
Author

Hi I really appreciate the tip.

For days trying how to read varaibles within a macro.

Thanks