Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How to open a .pdf outside Stata with a Stata command


From   Eric Booth <[email protected]>
To   [email protected]
Subject   Re: st: How to open a .pdf outside Stata with a Stata command
Date   Tue, 18 Dec 2012 10:12:14 -0600

<>
Also, preview.app will re-open the new pdf along with the old pdf if you run this command repeatedly, but other OSX pdf readers (adobe, sumatra, skim) may need to close first, or you may not want both the old and new versions of the pdf to open simultaneously in Preview.app -- either way, consider including an 'osascript' shell command to control closing programs or documents that are already open.  Adding this line to the -openmypdf- program I suggested would do the trick:

	!osascript -e 'tell application "Preview.app" to quit'

If you are doing a lot of this type of control of programs outside of Stata on OSX, consider learning the very useful open scripting (osa) commands for terminal.

- Eric



On Dec 18, 2012, at 10:02 AM, Eric Booth <[email protected]> wrote:

> <>
> 
> On a mac, just write a program that sends the 'open' command to the terminal , so :
> 
> cap program drop openmypdf
> program define openmypdf
> syntax anything
> 	!open -a Preview.app "`anything'"
> end
> 
> 
> openmypdf myfile.pdf
> 
> 
> would work.  Or make the program more general to any file (which utilizes the default program in the OS to open the file) with something like:
> 
> 
> cap program drop openmacfile
> program define openmacfile
> syntax anything
> 	!open  "`anything'"
> end
> 
> openmacfile myfile.docx
> 
> 
> or just put the command in your do-file:   !open  "myfile.ext"
> 
> P.S. the toy commands you mention to use iTunes, etc. on a mac from Stata are here:  http://www.eric-a-booth.com/Home/software
> 
> - Eric
> __
> [email protected]
> 
> 
> 
> On Dec 18, 2012, at 9:53 AM, Richard Svensson <[email protected]> wrote:
> 
>> I read about a user-written program that enable the Stata-user to control iTunes on a Mac computer, and another program that makes it possible to Google-search inside Stata. So it seems that it's possible (at least on Mac) to control other softwares from Stata.
>> 
>> What I am looking for, or trying to write, is a Stata-command that open a file (.pdf) outside Stata.
>> 
>> Do you know of any way to solve this? Or do you know where I might find information about this in my 
>> struggle with this problem? Any important key words that might help me?
>> 
>> Richard Svensson
>> The QoG Institute
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
> 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index