active doc question

Get help using and writing Nisus Writer Pro macros.
Post Reply
js
Posts: 229
Joined: 2007-04-12 14:59:36

active doc question

Post by js » 2014-05-03 06:53:40

I have an open document called "MYDOC". I would like to test whether it is active and if not make it active. I wrote

Code: Select all

$doc = Document.active
if $doc = "MYDOC"
	prompt "$doc is active"
else
	Document.setActive $doc
end
What's wrong with this? The macro doesn't complain. But whether MYDOC is actually active or not, I always get the answer that it is.

User avatar
phspaelti
Posts: 948
Joined: 2007-02-07 00:58:12
Location: Japan

Re: active doc question

Post by phspaelti » 2014-05-03 15:36:39

Two problems:
  1. "=" is an assignment, "==" is a comparison
  2. $doc is an object
Try

Code: Select all

if $doc.name == "MYDOC"
philip

js
Posts: 229
Joined: 2007-04-12 14:59:36

Re: active doc question

Post by js » 2014-05-04 06:23:28

Glad to have you helping. Thank You.

Post Reply