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

Is there a way to paste contents into a MS Word template automatically?

Expand Messages
  • Steve
    Hi Everybody, I create legal descriptions of land parcels in NoteTab, but all the clients want them to be in an MS Word doc. I can do this with the standard
    Message 1 of 15 , Jun 27, 2010
    • 0 Attachment
      Hi Everybody,

      I create legal descriptions of land parcels in NoteTab, but all the clients want them to be in an MS Word doc.

      I can do this with the standard Copy/Paste tools, but would like something faster and automatic.

      The Word template (.dot) file has a header and footer that I need to keep.

      I could open the .txt file in Notetab, and create a clip to select all and copy to clipboard,

      but what is the "clip" way to paste it into the (unopened) Word template file, while keeping the Word header and footer?

      In other words, I want to copy the contents of the text file and insert it into a new word doc based on the ".dot" template.

      Any guidance is appreciated.

      Thanks,

      Steve (NoteTab Pro 6.12f/v)
    • Axel Berger
      ... I have no Microsoft Office and no chance to try this out, but my first approach would be to insert a unique recognizable string into the .doc, like
      Message 2 of 15 , Jun 27, 2010
      • 0 Attachment
        Steve wrote:
        > In other words, I want to copy the contents of the text file
        > and insert it into a new word doc based on the ".dot" template.

        I have no Microsoft Office and no chance to try this out, but my first
        approach would be to insert a unique recognizable string into the .doc,
        like "yzqwgfa-replace this-yzqwgfa" and then use search and replace in
        NoteTab to insert your teyxt in its stead. In the older .doc versions I
        could find the text as uncompressed ASCII text so this might have a
        chance of working.

        Axel
      • Alec Burgess
        ... Hmm ... interesting approach - I though I d read somewhere that new Word docx files were actually some kind of XML format which might have allowed this but
        Message 3 of 15 , Jun 27, 2010
        • 0 Attachment
          On 2010-06-27 18:11, Axel Berger wrote:
          > Steve wrote:
          > > In other words, I want to copy the contents of the text file
          > > and insert it into a new word doc based on the ".dot" template.
          >
          > I have no Microsoft Office and no chance to try this out, but my first
          > approach would be to insert a unique recognizable string into the .doc,
          > like "yzqwgfa-replace this-yzqwgfa" and then use search and replace in
          > NoteTab to insert your teyxt in its stead. In the older .doc versions I
          > could find the text as uncompressed ASCII text so this might have a
          > chance of working.
          Hmm ... interesting approach - I though I'd read somewhere that new Word
          docx files were actually some kind of XML format which might have
          allowed this but after d/l'ing one via google it looks completely binary
          inside.

          Steve: depending on how much work (ie getting over a learning curve) you
          want to put into this an approach using a macro-scripting language - eg.
          (free) AutoIT might be workable. Its also possible (though I have
          nothing but minimal experience with it) to "drive" an external
          application (in this case Word) from within a clip - basically the same
          approach as with AutoIT.

          --
          Regards ... Alec (buralex@gmail& WinLiveMess - alec.m.burgess@skype)
        • John Shotsky
          Docx files are zip files. Change the file type and extract to see the files. Regards, John From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com]
          Message 4 of 15 , Jun 27, 2010
          • 0 Attachment
            Docx files are zip files. Change the file type and extract to see the files.

            Regards,
            John

            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Alec Burgess
            Sent: Sunday, June 27, 2010 16:10
            To: ntb-clips@yahoogroups.com
            Subject: Re: [Clip] Is there a way to paste contents into a MS Word template automatically?


            On 2010-06-27 18:11, Axel Berger wrote:
            > Steve wrote:
            > > In other words, I want to copy the contents of the text file
            > > and insert it into a new word doc based on the ".dot" template.
            >
            > I have no Microsoft Office and no chance to try this out, but my first
            > approach would be to insert a unique recognizable string into the .doc,
            > like "yzqwgfa-replace this-yzqwgfa" and then use search and replace in
            > NoteTab to insert your teyxt in its stead. In the older .doc versions I
            > could find the text as uncompressed ASCII text so this might have a
            > chance of working.
            Hmm ... interesting approach - I though I'd read somewhere that new Word
            docx files were actually some kind of XML format which might have
            allowed this but after d/l'ing one via google it looks completely binary
            inside.

            Steve: depending on how much work (ie getting over a learning curve) you
            want to put into this an approach using a macro-scripting language - eg.
            (free) AutoIT might be workable. Its also possible (though I have
            nothing but minimal experience with it) to "drive" an external
            application (in this case Word) from within a clip - basically the same
            approach as with AutoIT.

            --
            Regards ... Alec (buralex@gmail& WinLiveMess - alec.m.burgess@skype)



            [Non-text portions of this message have been removed]
          • hsavage
            ... Steve, I use Office/Word 97 to do something sort of similar. Would it not be feasible to construct the legal description entirely in NoteTab, and save it
            Message 5 of 15 , Jun 27, 2010
            • 0 Attachment
              Steve wrote:
              > Hi Everybody,
              >
              > I create legal descriptions of land parcels in NoteTab, but
              > all the clients want them to be in an MS Word doc.
              >
              > I can do this with the standard Copy/Paste tools, but would
              > like something faster and automatic.
              >
              > The Word template (.dot) file has a header and footer that
              > I need to keep.
              >
              > I could open the .txt file in Notetab, and create a clip
              > to select all and copy to clipboard,
              >
              > but what is the "clip" way to paste it into the (unopened)
              > Word template file, while keeping the Word header and footer?
              >
              > In other words, I want to copy the contents of the text file
              > and insert it into a new word doc based on the ".dot" template.
              >
              > Any guidance is appreciated.
              >
              > Thanks,
              >
              > Steve (NoteTab Pro 6.12f/v)

              Steve,

              I use Office/Word 97 to do something sort of similar. Would it not
              be feasible to construct the legal description entirely in NoteTab,
              and save it as a text file.

              When finished, load the '.dot' template into Word, this should create
              a new '.doc' file from the template. Place the cursor at the desired
              insertion point in the '.doc' file, select 'Insert' from the menubar
              at the top of window, go down the menu choices and click 'File...'.

              The 'Insert File' dialog will open, change the file type at the
              bottom of the dialog to '*.txt', find and select the .txt file to
              load and it should load starting at the cursor point and leaving your
              header and footer intact.

              I don't know what your .dot template file looks like but this method
              works for me when loading a 1/2 mb file into a template.

              ·············································
              ºvº SL_day# 179 - created 2010.06.28_01.04.08

              Newspaper HeadLine...
              • Farmer Bill Dies in House

              € hrs € hsavage € pobox € com
            • Don Daugherty
              ... At this point I would invoke a Clip that 1. Copies the desired text. 2. Starts Word and creates a new document based on the desired template. 3. Sets the
              Message 6 of 15 , Jun 28, 2010
              • 0 Attachment
                On 6/28/2010 1:30 AM, hsavage wrote:
                > Steve wrote:
                > > Hi Everybody,
                > >
                > > I create legal descriptions of land parcels in NoteTab, but
                > > all the clients want them to be in an MS Word doc.
                > >
                > > I can do this with the standard Copy/Paste tools, but would
                > > like something faster and automatic.
                > >
                > > The Word template (.dot) file has a header and footer that
                > > I need to keep.
                > >
                > > I could open the .txt file in Notetab, and create a clip
                > > to select all and copy to clipboard,
                > >
                > > but what is the "clip" way to paste it into the (unopened)
                > > Word template file, while keeping the Word header and footer?
                > >
                > > In other words, I want to copy the contents of the text file
                > > and insert it into a new word doc based on the ".dot" template.
                > >
                > > Any guidance is appreciated.
                > >
                > > Thanks,
                > >
                > > Steve (NoteTab Pro 6.12f/v)
                >
                > Steve,
                >
                > I use Office/Word 97 to do something sort of similar. Would it not
                > be feasible to construct the legal description entirely in NoteTab,
                >
                At this point I would invoke a Clip that
                1. Copies the desired text.
                2. Starts Word and creates a new document based on the desired template.
                3. Sets the cursor at the desired insertion point.
                4. Pastes the text previously copied in NoteTab.
                5. Saves (in Word) the resulting file.

                The Clip would read something like this (I say something like because I
                don't have Word so I'm substituting OpenOffice Writer for illustration
                Purposes):
                ^!Menu "Edit/Copy All"
                ^!Shell "C:\Program Files\OpenOffice.org 3\program\swriter.exe"
                -n(<template filename>)
                ; NOTE If the desired template is set as the default, then '
                -n(<template filename>)' may be omitted.
                ; Now wait for Writer (Word) to open
                ^!Delay 1
                ^!IfMatch "Untitled \d+ - OpenOffice.org Writer" "^$GetAppTitle$" Next
                Else Skip_-1
                ; Writer is now open
                ^!FocusApp "Untitled \d+ - OpenOffice.org Writer"
                ; Writer now has the focus so NoteTab 'keyboard" commands will act on
                Writer.
                ^!KeyboardDelay 100
                ; Keyboard commands will "type" at a rate of 10 char/sec (100ms delay
                between chars)
                ; Now paste copied text and do a SaveAs (you fill in the file name
                unless you want to modify the clip so it does it for you.)
                ^!Keyboard Ctrl+V
                ^!Keyboard Ctrl+Shift+S
              • diodeom
                ... If it has to be done in older Word (instead of in plain xml of 2007/2010 versions) and there is no alternative to launching it, it probably wouldn t hurt
                Message 7 of 15 , Jun 28, 2010
                • 0 Attachment
                  hsavage <hsavage@...> wrote:
                  >
                  > Steve wrote:
                  > > Hi Everybody,
                  > >
                  > > I create legal descriptions of land parcels in NoteTab, but
                  > > all the clients want them to be in an MS Word doc.
                  > >
                  > <snip>
                  >
                  > Steve,
                  >
                  > I use Office/Word 97 to do something sort of similar. Would it not
                  > be feasible to construct the legal description entirely in NoteTab,
                  > and save it as a text file.
                  >
                  > When finished, load the '.dot' template into Word, this should create
                  > a new '.doc' file from the template. Place the cursor at the desired
                  > insertion point in the '.doc' file, select 'Insert' from the menubar
                  > at the top of window, go down the menu choices and click 'File...'.
                  >
                  > The 'Insert File' dialog will open, change the file type at the
                  > bottom of the dialog to '*.txt', find and select the .txt file to
                  > load and it should load starting at the cursor point and leaving your
                  > header and footer intact.
                  >
                  > I don't know what your .dot template file looks like but this method
                  > works for me when loading a 1/2 mb file into a template.
                  >


                  If it has to be done in older Word (instead of in plain xml of 2007/2010 versions) and there is no alternative to launching it, it probably wouldn't hurt to employ Word's macro recorder -- to avoid piddling with most keyboard shortcuts and delays from within NT. I'd still start (or give focus to) Word and its very key-combo-activated macro via a NoteTab clip, and let the macro handle starting a new doc (from the desired template), positioning of the cursor (if needed), inserting text from some once-set file/path that NoteTab dumps content to, saving it as some temp.doc and closing it. After that the NoteTab clip could resume and rename the freshly made document to what it needs to be called, archive it someplace else, cook up an email or whatever. Maybe even grab and pitch another text to repeat the cycle.

                  If Word is already running, this process takes just an Augenblick (in my tests). Obviously, if the monster is not up, a conditional fork has to serve a couple of long seconds (!) delay for Word to gather its hefty butt and report for duty.

                  (BTW, I speculate that this whole issue (c|sh)ould be easily approached entirely from its rear end, if one happened to be both cozy & happy with VBA.)
                • diodeom
                  I sense that for passing to Word (or other apps) more complex text snippets fist conveniently manipulated/established in NoteTab (e.g. path, file name, title,
                  Message 8 of 15 , Jun 28, 2010
                  • 0 Attachment
                    I sense that for passing to Word (or other apps) more complex text snippets fist conveniently manipulated/established in NoteTab (e.g. path, file name, title, headings, paragraphs, etc.), an ini file could be perhaps well utilized. NT would write it, then Word macro would read it -- and drop proper values in appropriate spots of a dot template:

                    System.PrivateProfileString("C:\Test\Sample.ini", "Section", "Item")

                    Has anyone (willing-to-share) played with that?
                  • vanwasdi
                    Perhaps you could try the following make a clip that (1) makes a vbscript file (e.g. sendtoword.vbs) and (2) runs it afterwards try with the vbs code that is
                    Message 9 of 15 , Jun 29, 2010
                    • 0 Attachment
                      Perhaps you could try the following

                      make a clip that (1) makes a vbscript file (e.g. sendtoword.vbs) and (2) runs it afterwards

                      try with the vbs code that is between ====
                      change "yourtemplate.dot" and "your_file_made_in_notetab.txt"

                      see the Hey scripting guy's archive to refine your script with printing and saving: http://www.microsoft.com/downloads/details.aspx?FamilyID=5f5e0bda-923a-4744-8289-afb73f6a5ed8&displaylang=en

                      ======================================================================
                      Set objWord = CreateObject("Word.Application")
                      objWord.Visible = True
                      sLetterTemplate = "yourtemplate.dot"
                      Set objDoc = objWord.Application.Documents.Add(sLetterTemplate)
                      Set objSelection = objWord.Selection
                      objSelection.InsertFile("your_file_made_in_notetab.txt")
                      ======================================================================

                      Greetings,
                      Dirk
                    • vanwasdi
                      Perhaps you could try the following make a clip that (1) makes a vbscript file (e.g. sendtoword.vbs) and (2) runs it afterwards try with the vbs code that is
                      Message 10 of 15 , Jun 29, 2010
                      • 0 Attachment
                        Perhaps you could try the following

                        make a clip that (1) makes a vbscript file (e.g. sendtoword.vbs) and (2) runs it afterwards

                        try with the vbs code that is between ====
                        change "yourtemplate.dot" and "your_file_made_in_notetab.txt"

                        see the Hey scripting guy's archive to refine your script with printing and saving: http://www.microsoft.com/downloads/details.aspx?FamilyID=5f5e0bda-923a-4744-8289-afb73f6a5ed8&displaylang=en

                        ======================================================================
                        Set objWord = CreateObject("Word.Application")
                        objWord.Visible = True
                        sLetterTemplate = "yourtemplate.dot"
                        Set objDoc = objWord.Application.Documents.Add(sLetterTemplate)
                        Set objSelection = objWord.Selection
                        objSelection.InsertFile("your_file_made_in_notetab.txt")
                        ======================================================================

                        Greetings,
                        Dirk
                      • Steve
                        I appreciate everyone s ideas, thank you! But I am skeered of VB and scripts, was checking to see if I was missing something simple already in NTab. Will
                        Message 11 of 15 , Jun 29, 2010
                        • 0 Attachment
                          I appreciate everyone's ideas, thank you!

                          But I am skeered of VB and scripts, was checking to see if I was missing something simple already in NTab.

                          Will prolly just copy my .txt file to .doc.

                          Thanks,

                          Steve

                          --- In ntb-clips@yahoogroups.com, "vanwasdi" <dirk.vanwassenhove@...> wrote:
                          >
                          >
                          >
                          > Perhaps you could try the following
                          >
                          > make a clip that (1) makes a vbscript file (e.g. sendtoword.vbs) and (2) runs it afterwards
                          >
                          > try with the vbs code that is between ====
                          > change "yourtemplate.dot" and "your_file_made_in_notetab.txt"
                          >
                          > see the Hey scripting guy's archive to refine your script with printing and saving: http://www.microsoft.com/downloads/details.aspx?FamilyID=5f5e0bda-923a-4744-8289-afb73f6a5ed8&displaylang=en
                          >
                          > ======================================================================
                          > Set objWord = CreateObject("Word.Application")
                          > objWord.Visible = True
                          > sLetterTemplate = "yourtemplate.dot"
                          > Set objDoc = objWord.Application.Documents.Add(sLetterTemplate)
                          > Set objSelection = objWord.Selection
                          > objSelection.InsertFile("your_file_made_in_notetab.txt")
                          > ======================================================================
                          >
                          > Greetings,
                          > Dirk
                          >
                        • diodeom
                          Skeered or not, you re certainly credited with opening a very interesting (at least to me) can of worms. :) For a quick n easy copy n paste action here s a
                          Message 12 of 15 , Jun 29, 2010
                          • 0 Attachment
                            Skeered or not, you're certainly credited with opening a very interesting (at least to me) can of worms. :)

                            For a quick'n'easy copy'n'paste action here's a clip following Dirk's (thank you, Dirk!) smooth outline. It only requires an edit of the first variable, where a ¡fully qualified! location of your template needs to be entered.

                            H="txt2doc"
                            ^!Set %tpl%=<full_path/template.dot>
                            ^!Set %file%=^#
                            ^!Set %x%=^$GetExt(^##)$
                            ^!Set %lib%=^$GetLibraryFileName$
                            ^!Set %vbs%=^$GetPath(^%lib%)$txt2doc.vbs
                            ^!IfMatch "[^\\\/]++" "^%file%" Alert
                            ^!IfFalse ^$IsModified$ Skip_3
                            ^!Skip Save changes to the current doc before proceeding?
                            ^!Goto Skip
                            ^!Save
                            ^!Set %source%=^$GetDocIndex$
                            ^!SetScreenUpdate 0
                            ^!Menu File/New
                            ;Content of the VBScript file:
                            ;(long line divided for clarity and clean copying)
                            ^!InsertText Set W = CreateObject("Word.Application")
                            ^!InsertText ^pW.Application.Documents.Add ("^%tpl%")
                            ^!InsertText ^pW.Selection.InsertFile("^%file%^%x%")
                            ^!InsertText ^pSet doc = W.ActiveDocument
                            ^!InsertText ^pdoc.SaveAs "^%file%.doc"
                            ^!InsertText , wdFormatDocument97^p
                            ^!InsertText doc.Close^p
                            ^!InsertText W.Quit^p
                            ^!InsertText MsgBox "New MS Word 97 file:" &
                            ^!InsertText vbCrLf & "^%file%.doc"
                            ^!Save As ^%vbs%
                            ^!Close
                            ^!SetDocIndex ^%source%
                            ^!^%vbs%
                            ^!Goto End
                            :Alert
                            ^!Prompt Current doc has to reside on disk, not just memory!
                            :End
                            ^!ClearVariable %tpl%
                            ^!ClearVariable %file%
                            ^!ClearVariable %x%
                            ^!ClearVariable %lib%
                            ^!ClearVariable %vbs%
                            ^!ClearVariable %source%

                            The clip makes a Word doc file from a NT document currently in focus and drops it in the very location of this original txt file. It's only a first draft, but it's been so far quite fine in a few tests on my box with Word 2007. All happens out of sight and it might take a second or two (or on some systems even longer, I'd imagine) before the confirmation message appears.

                            It leaves a tiny txt2doc.vbs file in the library of the clip -- to be rewritten over and over. To get rid of it "the clip way" (instead of hunting it down manually), run:

                            ^!Delete ^$GetPath(^$GetLibraryFileName$)$txt2doc.vbs

                            A can of worms indeed -- when I consider the possibilities of easily passing not just a single body of text (which can be simply pasted, sure) to a "guarded" app, but a bunch of variable snippets or paragraphs in precise spots of a multi-sectional destination file. (Among others, my heaviest cross to bear in that regard is... WordPerfect.)


                            --- In ntb-clips@yahoogroups.com, "Steve" <jsteveadams@...> wrote:
                            >
                            > I appreciate everyone's ideas, thank you!
                            >
                            > But I am skeered of VB and scripts, was checking to see if I was missing something simple already in NTab.
                            >
                            > Will prolly just copy my .txt file to .doc.
                            >
                            > Thanks,
                            >
                            > Steve
                            >
                            > --- In ntb-clips@yahoogroups.com, "vanwasdi" <dirk.vanwassenhove@> wrote:
                            > >
                            > >
                            > >
                            > > Perhaps you could try the following
                            > >
                            > > make a clip that (1) makes a vbscript file (e.g. sendtoword.vbs) and (2) runs it afterwards
                            > >
                            > > try with the vbs code that is between ====
                            > > change "yourtemplate.dot" and "your_file_made_in_notetab.txt"
                            > >
                            > > see the Hey scripting guy's archive to refine your script with printing and saving: http://www.microsoft.com/downloads/details.aspx?FamilyID=5f5e0bda-923a-4744-8289-afb73f6a5ed8&displaylang=en
                            > >
                            > > ======================================================================
                            > > Set objWord = CreateObject("Word.Application")
                            > > objWord.Visible = True
                            > > sLetterTemplate = "yourtemplate.dot"
                            > > Set objDoc = objWord.Application.Documents.Add(sLetterTemplate)
                            > > Set objSelection = objWord.Selection
                            > > objSelection.InsertFile("your_file_made_in_notetab.txt")
                            > > ======================================================================
                            > >
                            > > Greetings,
                            > > Dirk
                            > >
                            >
                          • diodeom
                            ... Shoot, I prolly shouldn t have put the tag brackets in the line to edit. They were only meant to screem here, edit here! but now I see that someone less
                            Message 13 of 15 , Jun 29, 2010
                            • 0 Attachment
                              I wrote:
                              >
                              > It only requires an edit of the first variable, where a ¡fully qualified! location of your template needs to be entered.
                              >
                              > H="txt2doc"
                              > ^!Set %tpl%=<full_path/template.dot>
                              >

                              Shoot, I prolly shouldn't have put the tag brackets in the line to edit. They were only meant to screem "here, edit here!" but now I see that someone less familiar with clips could easily assume that they actually belong there as part of the script. Sorry.
                            • Steve
                              Thanks diodeom, That sure does work! I appreciate that. Sometimes I have a hundred of these to do at a time, and this surely is fantastic help. So the .vbs fle
                              Message 14 of 15 , Jun 30, 2010
                              • 0 Attachment
                                Thanks diodeom,

                                That sure does work! I appreciate that. Sometimes I have a hundred of these to do at a time, and this surely is fantastic help.

                                So the .vbs fle is created solely from what is in the clip?

                                This is asking too much, but is there a way this clip can be altered to do the same thing, but in Open Office.org 3.1?

                                Thank you diodeom, and Dirk too!

                                -Steve
                              • diodeom
                                ... If your desired final document format is now OpenOffice .odt, I wouldn t bother with VB at all, but -- the way I see it -- have a copy of the template file
                                Message 15 of 15 , Jul 1, 2010
                                • 0 Attachment
                                  "Steve" <jsteveadams@...> wrote:
                                  >
                                  > This is asking too much, but is there a way this clip can be altered to do the same thing, but in Open Office.org 3.1?
                                  >

                                  If your desired final document format is now OpenOffice .odt, I wouldn't bother with VB at all, but -- the way I see it -- have a copy of the template file unzipped in some permanent location where NoteTab clip can repetitively populate the content.xml file with your text. It would zip it afterwards along with all the associated files (via a command line zipping utility) to some desired location as nameofnewfile.odt. If you have a bunch of these text files to do at once, the clip could cycle through a whole batch (directory) of them with one click. No need to load OpenOffice. The same goes for the MS Word 2007/10 alternative.

                                  I'm not anxious to load yet another bloatware suite just for testing, but I'll try this scheme first with Word's .docx...
                                Your message has been successfully submitted and would be delivered to recipients shortly.