Re: MS Word Automation

From: Andreas (nobody_at_home.com)
Date: 03/24/05


Date: Thu, 24 Mar 2005 22:41:54 +1200

Create a object variable for the document itself.
Then refer to the document variable instead of the application variable.
Also, you might want to use a With ... End With.

Regards,
Andreas

Michael wrote:
> I am trying to export a large number of records one at a time into a word
> template .dot file from access. The problem that I am having is that each
> time a new document is created from the template I have to click on the
> header of the Word application for the code in access to progress. The code
> just seems to hand after the document is created. Aside from this
> undesirable user intervention the sub-routine seems to work. How do I get
> rid of the pause?
>
> I used the following code:
> Set objWord = CreateObject("Word.Application")
> objWord.Documents.Add "The Path To The Template IS Here", _
> NewTemplate:=False, DocumentType:=0)
> ObjWord.Application.Visible =True
> .....This is where we pause until I click on the Header of the Word App
> objWord.Slection.MoveDown Unit:=wdLine, count:=12
> The previous line skips past the protected(Form) sections of the document
> Fonts are set and the fields are entered here.
> objWord.Activedocument.SaveAs "File Path and name"
> objWord.ActiveDocument.Close
> objWord.Quit
>
> Is there some way for me to give focus to Word from the code in Access
> without manually clicking the Word header with each pass of the code?
>
> Thanks,
> Michael
>



Relevant Pages

  • Re: font changes in letterhead macro
    ... While I use macros to insert letterhead content, I do it because I want to ... ' First part operates only in template other than "Kenyon Legal ... ' The name of the Base Template is stored ... ' Replaces Header and FirstPageHeader with contents from ...
    (microsoft.public.word.vba.beginners)
  • Re: MAGIX - MEP Titles
    ... white body, but the header comes out grey on the monitor, not yellow! ... And other apparently identically constructed titles earlier in the ... title as the "Scrolling text on the right" preset except without ... as a template, will it capture the separate style elements? ...
    (rec.video.desktop)
  • Re: Inserting Logo in Header
    ... Try putting the AutoText into a separate global template. ... The template always has the logo (which can also be an AutoText ... > a letterhead logo, which has been saved as AutoText into the header. ...
    (microsoft.public.word.vba.general)
  • Re: I am having difficulty with deleting headers and footers
    ... Here is some general info on moving from Word Perfect to Word. ... As for converting documents from Word Perfect to _use_ in Word... ... To use a template within Word, use File => New and pick your template. ... How to set up letterhead or some other document where you want one header ...
    (microsoft.public.word.newusers)
  • Re: AutoText entry
    ... Those templates can call in or incorporate aspects of a base template as ... Letterhead Tips and Instructions ... > header with "Page 2", ... > using an AutoText entry with a button on the toolbar ...
    (microsoft.public.word.formatting.longdocs)