Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 11 of 11 (93 Views)

Re: Help with a Macro in MNL or Lisp

09-06-2013 01:07 PM in reply to: sbrusco

sbrusco wrote:

Henrique, you are a blessing to me.

 

If i may please press you for one more question? Once the code opens the file, its work is done. Can i leave the Word document open and terminate the lisp?

 

Thanks you so much for all your help.

 

Sal


You're welcome, Sal

after opening the document, you can close the shell window, even AutoCAD, and the .doc remains open.

 

EDIT:

Sal, if you do not like the shell window, is possible to open the. doc in another way, but you must correct the path to your WINWORD.EXE...

 

(defun c:doc (/ DOC FILE I II III PATH)

(defun DoDoc (/ FNAME)
  (if (findfile file)
    (command "sh" (strcat "\"" file "\""))
    (progn
      (setq fname (open file "W"))
      (close fname)
      (startapp "C:\\Program Files\\Microsoft Office\\Office???\\WINWORD.EXE" (strcat "\""file"\"" ))
    );; progn
  );; if  
);; DoDoc

  (setq path (getvar 'dwgprefix))
  (cond ((and (setq i (vl-string-search "Projects" path))
	   (setq ii (vl-string-search "\\" path (1+ i)))
	   (setq iii (vl-string-search "\\" path (1+ ii)))
	   (setq doc (strcat (substr path (+ ii 2) (- (- iii ii) 1)) ".doc"))
	   (setq file (strcat (substr path 1 (1+ iii)) doc))
      );; and
	 (doDoc))
	((and (setq i (vl-string-search "\\" path))
	   (setq ii (vl-string-search "\\" path (1+ i)))
	   (setq doc (strcat (substr path (+ i 2) (- (- ii i) 1)) ".doc"))
	   (setq file (strcat (substr path 1 (1+ ii)) doc))
      );; and
	 (DoDOc))
	);; cond
  (princ)
);; doc

 in the line

"C:\\Program Files\\Microsoft Office\\Office???\\WINWORD.EXE"

you must put the correct path to your WINWORD.EXE...

 

hope that helps

 

Henrique

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community