Loading ...
Sorry, an error occurred while loading the content.

Re: WPMac macro question

Expand Messages
  • em315
    I ve now got a PDF-writing macro working in a primitive sort of way. What it does is this: In WPMac, the macro creates a file named OpenPDF.file in the folder
    Message 1 of 15 , Nov 20, 2012
    • 0 Attachment
      I've now got a PDF-writing macro working in a primitive sort of way. What it does is this:

      In WPMac, the macro creates a file named OpenPDF.file in the folder that contains a folder action script, and then prints the current document by writing a print file to that same folder (as in the printing system that we both use).

      On the OS X side, when the folder action script detects the print file, it checks for the existence of the OpenPDF.file file, and, if it finds it, deletes it, and then converts the print file from PS to PDF and opens the resulting file in Preview. If the folder action script doesn't find that file, it prints the print file to the default printer.

      The next thing to do is to write a similar macro that will create a file named WritePDF.file; this will signal the folder action script to write a PDF file to the desktop (or some other folder?) with the same name as the WP document. That will be a bit more complicated.

      Macro question: what is the IF THEN statement that checks whether a window is open in WPMac, so that a PDF-writing macro will refuse to run if there is no document open to "print" to PDF?


      --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:
      >
      > I was afraid of that. Would it be possible for a PDF-writing macro to do the following:
      >
      > 1. Write a file to the same folder to which the print file will be written; the file will be named something like MakePDF.
      >
      > 2. Then write the print file to the same folder.
      >
      > Meanwhile, on the OS X side, the folder action script will see that a MakePDF file has been written, and will wait (say) one minute for a .PS file to be written to the same folder. If a .PS file does get written in that period, the folder action script will delete the MakePDF file and convert the .PS file to a PDF file, with the same name as the name part of the .PS file. If the name of the .PS file begins with "untitled" (or whatever WP uses), then the PDF file will get an arbitrary filename based on the current date and time.
      >
      > Does this sound plausible? This is somewhat similar to the way the PDF-writing macro works in the system I've devised for using WPDOS under OS X.
      >
      > --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@> wrote:
      > >
      > > I don't see how a WP Mac macro could do this. A folder action script could change the name of a file that lands in the folder, but would need a basis for the decision whether to change the name.
      > >
      > > John R.
      > >
      > >
      > >
      > > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
      > > >
      > > > This is a question for John and any other expert:
      > > >
      > > > Is it possible for a macro to do the following:
      > > >
      > > > If printing to a virtual printer (a "printer" that creates a PostScript file), when the Save dialog opens, change the name of the output file so that (for example) the name filename.ps is changed to something like filename-pdf.ps.
      > > >
      > > > The point of this is to modify the filename so that, when the file is saved to a folder in OS X, a folder action script attached to that folder can recognize the "-pdf.ps" in the name, and automatically create a PDF file.
      > > >
      > > > This can't be recorded. Is it possible to write such a macro?
      > > >
      > >
      >
    • John R
      That s easy enough. A WP macro that makes a document and saves it in a given place with a given name is: New Document Type ( ); a space Save As ( Hard
      Message 2 of 15 , Nov 20, 2012
      • 0 Attachment
        That's easy enough. A WP macro that makes a document and saves it in a given place with a given name is:

        New Document
        Type ( ); a space
        Save As ("Hard Disk:Users:HomeFolder:MakePDF")
        Close

        The path has to be more or less hard-coded though. WP only knows the path to the startup disk and to its application folder. But if you run the macro from an Applescript you can pass the file name and path to the macro as:

        tell application "WordPerfect"
        Do Script {"MakePDFmacro", "Hard Disk:Users:HomeFolder:MakePDF"}
        end tell

        and the macro would then be:

        New Document
        Type ( )
        Save As (ScriptVar01)
        Close




        --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:
        >
        > I was afraid of that. Would it be possible for a PDF-writing macro to do the following:
        >
        > 1. Write a file to the same folder to which the print file will be written; the file will be named something like MakePDF.
        >
        > 2. Then write the print file to the same folder.
        >
        > Meanwhile, on the OS X side, the folder action script will see that a MakePDF file has been written, and will wait (say) one minute for a .PS file to be written to the same folder. If a .PS file does get written in that period, the folder action script will delete the MakePDF file and convert the .PS file to a PDF file, with the same name as the name part of the .PS file. If the name of the .PS file begins with "untitled" (or whatever WP uses), then the PDF file will get an arbitrary filename based on the current date and time.
        >
        > Does this sound plausible? This is somewhat similar to the way the PDF-writing macro works in the system I've devised for using WPDOS under OS X.
        >
        > --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@> wrote:
        > >
        > > I don't see how a WP Mac macro could do this. A folder action script could change the name of a file that lands in the folder, but would need a basis for the decision whether to change the name.
        > >
        > > John R.
        > >
        > >
        > >
        > > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
        > > >
        > > > This is a question for John and any other expert:
        > > >
        > > > Is it possible for a macro to do the following:
        > > >
        > > > If printing to a virtual printer (a "printer" that creates a PostScript file), when the Save dialog opens, change the name of the output file so that (for example) the name filename.ps is changed to something like filename-pdf.ps.
        > > >
        > > > The point of this is to modify the filename so that, when the file is saved to a folder in OS X, a folder action script attached to that folder can recognize the "-pdf.ps" in the name, and automatically create a PDF file.
        > > >
        > > > This can't be recorded. Is it possible to write such a macro?
        > > >
        > >
        >
      • John R
        ... Any window, or a window of a given name?
        Message 3 of 15 , Nov 20, 2012
        • 0 Attachment
          --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:

          > Macro question: what is the IF THEN statement that checks whether a window is open in WPMac, so that a PDF-writing macro will refuse to run if there is no document open to "print" to PDF?

          Any window, or a window of a given name?
        • John R
          ... To check for any open window in WP: If (NumberOfWindows
          Message 4 of 15 , Nov 20, 2012
          • 0 Attachment
            --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@...> wrote:
            >
            > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
            >
            > > Macro question: what is the IF THEN statement that checks whether a window is open in WPMac, so that a PDF-writing macro will refuse to run if there is no document open to "print" to PDF?
            >
            > Any window, or a window of a given name?


            To check for any open window in WP:

            If (NumberOfWindows<1)
            ; no windows open
            End If


            To check for a window of a given name:

            On Error (error)
            Select Window ("OpenPDF")
            Alert ("You got it")
            Go (further)
            Label (error)
            Alert ("No such window as OpenPDF")
            Return
            ;
            Label (further)
            Alert ("Macro continues here")
          • em315
            The IF... statement was what I needed. Thank you. After adding it to the macro I was already using, I got this: If (NumberOfWindows 0) New Document Type (a)
            Message 5 of 15 , Nov 21, 2012
            • 0 Attachment
              The IF... statement was what I needed. Thank you. After adding it to the macro I was already using, I got this:

              If (NumberOfWindows>0)
              New Document
              Type (a)
              Save As ("WPMac HD:System Folder:WPMacAppData:OpenPDF.file")
              Close
              Print Options (1;32000;1;Document;Every Page;Forward;Print Overlay)
              Print (Document)
              Else
              Alert ("No document window open.")
              End If

              Sometime over the next few days, I'll try to add an opening menu ("Create a PDF file and open it in Preview?") and work on the OS X folder action script to refine it a bit. My guess is that you could do this far more elegantly than I ever will!

              --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@...> wrote:
              >
              > --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@> wrote:
              > >
              > > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
              > >
              > > > Macro question: what is the IF THEN statement that checks whether a window is open in WPMac, so that a PDF-writing macro will refuse to run if there is no document open to "print" to PDF?
              > >
              > > Any window, or a window of a given name?
              >
              >
              > To check for any open window in WP:
              >
              > If (NumberOfWindows<1)
              > ; no windows open
              > End If
              >
              >
              > To check for a window of a given name:
              >
              > On Error (error)
              > Select Window ("OpenPDF")
              > Alert ("You got it")
              > Go (further)
              > Label (error)
              > Alert ("No such window as OpenPDF")
              > Return
              > ;
              > Label (further)
              > Alert ("Macro continues here")
              >
            • em315
              One more WP macro question: Can a WP macro select a printer? Or does that require running an Applescript? Thanks!
              Message 6 of 15 , Nov 21, 2012
              • 0 Attachment
                One more WP macro question:

                Can a WP macro select a printer? Or does that require running an Applescript?

                Thanks!
              • John R
                A WP macro by itself can t select a printer. A macro can call an Applescript though: ;macro code Execute Apple Script ( name of script ) with only the name: WP
                Message 7 of 15 , Nov 21, 2012
                • 0 Attachment
                  A WP macro by itself can't select a printer. A macro can call an Applescript though:

                  ;macro code
                  Execute Apple Script ("name of script")

                  with only the name: WP will find it and run it from any mounted volume.



                  --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:
                  >
                  > One more WP macro question:
                  >
                  > Can a WP macro select a printer? Or does that require running an Applescript?
                  >
                  > Thanks!
                  >
                • em315
                  Hello John, Here s a curious thing about WP macros, and I wonder if you know a solution. The macro I m working on prints the current document to a virtual
                  Message 8 of 15 , Nov 21, 2012
                  • 0 Attachment
                    Hello John,

                    Here's a curious thing about WP macros, and I wonder if you know a solution.

                    The macro I'm working on prints the current document to a virtual printer. When I print the document manually, the print file takes the name of the document, followed by .ps. For example, if the document is titled "The Meaning of Life", then the print file is saved as "The Meaning of Life.ps".

                    But when a macro includes the Print command, the print file is named "untitled.ps", not "The Meaning of Life.ps".

                    Is there a way to force the Print command in the macro write the print file with the name of the document?

                    Thanks for any advice on this - and Happy Thanksgiving to all who celebrate the US variety of Thanksgiving.
                  • John R
                    That appears to be a program artifact. The WP macro command Rename File could fix the file once it s written. John R.
                    Message 9 of 15 , Nov 23, 2012
                    • 0 Attachment
                      That appears to be a program artifact. The WP macro command Rename File could fix the file once it's written.

                      John R.




                      --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:
                      >
                      > Hello John,
                      >
                      > Here's a curious thing about WP macros, and I wonder if you know a solution.
                      >
                      > The macro I'm working on prints the current document to a virtual printer. When I print the document manually, the print file takes the name of the document, followed by .ps. For example, if the document is titled "The Meaning of Life", then the print file is saved as "The Meaning of Life.ps".
                      >
                      > But when a macro includes the Print command, the print file is named "untitled.ps", not "The Meaning of Life.ps".
                      >
                      > Is there a way to force the Print command in the macro write the print file with the name of the document?
                      >
                      > Thanks for any advice on this - and Happy Thanksgiving to all who celebrate the US variety of Thanksgiving.
                      >
                    • em315
                      One more question, which I m only asking because the Scripting Guide and help file doesn t give an answer. When you Save As... in Text format, a prompt appears
                      Message 10 of 15 , Nov 23, 2012
                      • 0 Attachment
                        One more question, which I'm only asking because the Scripting Guide and help file doesn't give an answer.

                        When you Save As... in Text format, a prompt appears asking which text format to use. Is there any way to respond to that prompt in a script?

                        --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@...> wrote:
                        >
                        > That appears to be a program artifact. The WP macro command Rename File could fix the file once it's written.
                        >
                        > John R.
                        >
                        >
                        >
                        >
                        > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
                        > >
                        > > Hello John,
                        > >
                        > > Here's a curious thing about WP macros, and I wonder if you know a solution.
                        > >
                        > > The macro I'm working on prints the current document to a virtual printer. When I print the document manually, the print file takes the name of the document, followed by .ps. For example, if the document is titled "The Meaning of Life", then the print file is saved as "The Meaning of Life.ps".
                        > >
                        > > But when a macro includes the Print command, the print file is named "untitled.ps", not "The Meaning of Life.ps".
                        > >
                        > > Is there a way to force the Print command in the macro write the print file with the name of the document?
                        > >
                        > > Thanks for any advice on this - and Happy Thanksgiving to all who celebrate the US variety of Thanksgiving.
                        > >
                        >
                      • John R
                        I have looked for a way to script that, and can t find one. I haven t tried Prefab Player though.
                        Message 11 of 15 , Nov 23, 2012
                        • 0 Attachment
                          I have looked for a way to script that, and can't find one. I haven't tried Prefab Player though.



                          --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:
                          >
                          > One more question, which I'm only asking because the Scripting Guide and help file doesn't give an answer.
                          >
                          > When you Save As... in Text format, a prompt appears asking which text format to use. Is there any way to respond to that prompt in a script?
                          >
                          > --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@> wrote:
                          > >
                          > > That appears to be a program artifact. The WP macro command Rename File could fix the file once it's written.
                          > >
                          > > John R.
                          > >
                          > >
                          > >
                          > >
                          > > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
                          > > >
                          > > > Hello John,
                          > > >
                          > > > Here's a curious thing about WP macros, and I wonder if you know a solution.
                          > > >
                          > > > The macro I'm working on prints the current document to a virtual printer. When I print the document manually, the print file takes the name of the document, followed by .ps. For example, if the document is titled "The Meaning of Life", then the print file is saved as "The Meaning of Life.ps".
                          > > >
                          > > > But when a macro includes the Print command, the print file is named "untitled.ps", not "The Meaning of Life.ps".
                          > > >
                          > > > Is there a way to force the Print command in the macro write the print file with the name of the document?
                          > > >
                          > > > Thanks for any advice on this - and Happy Thanksgiving to all who celebrate the US variety of Thanksgiving.
                          > > >
                          > >
                          >
                        • em315
                          I worked around it in the latest version of my system (posted a few hours ago) by saving an RTF file with the name of the current document, then (in OS X)
                          Message 12 of 15 , Nov 24, 2012
                          • 0 Attachment
                            I worked around it in the latest version of my system (posted a few hours ago) by saving an RTF file with the name of the current document, then (in OS X) converting that file to text and reading its contents, and applying that name to the output PDF. I'm not sure I've got the timing right, but it seems to work.

                            --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@...> wrote:
                            >
                            > I have looked for a way to script that, and can't find one. I haven't tried Prefab Player though.
                            >
                            >
                            >
                            > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
                            > >
                            > > One more question, which I'm only asking because the Scripting Guide and help file doesn't give an answer.
                            > >
                            > > When you Save As... in Text format, a prompt appears asking which text format to use. Is there any way to respond to that prompt in a script?
                            > >
                            > > --- In wordperfectmac@yahoogroups.com, "John R" <johnrethorst@> wrote:
                            > > >
                            > > > That appears to be a program artifact. The WP macro command Rename File could fix the file once it's written.
                            > > >
                            > > > John R.
                            > > >
                            > > >
                            > > >
                            > > >
                            > > > --- In wordperfectmac@yahoogroups.com, "em315" <em315@> wrote:
                            > > > >
                            > > > > Hello John,
                            > > > >
                            > > > > Here's a curious thing about WP macros, and I wonder if you know a solution.
                            > > > >
                            > > > > The macro I'm working on prints the current document to a virtual printer. When I print the document manually, the print file takes the name of the document, followed by .ps. For example, if the document is titled "The Meaning of Life", then the print file is saved as "The Meaning of Life.ps".
                            > > > >
                            > > > > But when a macro includes the Print command, the print file is named "untitled.ps", not "The Meaning of Life.ps".
                            > > > >
                            > > > > Is there a way to force the Print command in the macro write the print file with the name of the document?
                            > > > >
                            > > > > Thanks for any advice on this - and Happy Thanksgiving to all who celebrate the US variety of Thanksgiving.
                            > > > >
                            > > >
                            > >
                            >
                          Your message has been successfully submitted and would be delivered to recipients shortly.