Re: coding question

Tech-Archive recommends: Fix windows errors by optimizing your registry



you have to set up an application reference not just a doc reference

'creates a new object which will be the word application
Dim objword As New word.Application

'activates the object
Set objword = CreateObject("word.Application")

'opens the document
objword.documents.Open "C:\Documents and Settings\WinXP\Desktop
\docname.doc"

'displays the application for use
objword.Visible = True

'will minimise the word application
objword.WindowState = wdWindowStateMinimize

'will close the application
objword.quit

as a note to use this you will have to reference the word library in
the code references
to do this

click on tool --> references
then scroll down to find
microsoft word X.X object library

where X.X is the version of word you use
ie
8.0 is word 97
9.0 is word 2000
10.0 is word 2002
11.0 is word 2003
12.0 is word 2007

remember any code you do in your vba in access which is needed to do
somethign in word you need to reference objword before it at all
times.


this can also be done for any of the office applications and cna be
quite useful for manipluating application as an example i use this
from word to generate an automatic report which my code in word opens
access and excel to gather and process information then saves the
results into microsoft word for use in a report.

hope this helps

Regards
Kelvan
.



Relevant Pages

  • Re: Word Automation: instance running, but cant use it?
    ... your app's reference to Word. ... > I'll remove the early binding ref and code in this case. ... >> Dim objWord as Word.Application ... >> This opens the document with an implicit reference to the Word ...
    (microsoft.public.word.vba.general)
  • Re: Activate Word object
    ... don't rely on references to Word's ActiveDocument. ... reference to the Target Document, ... I have noticed that if I don't set the objWord (application ... Activating early-on but the random behavior has me concerned? ...
    (microsoft.public.word.vba.general)
  • Re: Activate Word object
    ... You generally get a performance gain from running word with .Visible = ... reference to the Target Document, ... I have noticed that if I don't set the objWord (application ... Activating early-on but the random behavior has me concerned? ...
    (microsoft.public.word.vba.general)
  • Re: How do I Dim an MS Word object (Range)?
    ... Have you set a reference to Word yet? ... Dim objWord As Word.Application ... Is there a way to Dim r as an MSWord ...
    (microsoft.public.access.modulesdaovba)
  • RE: Opening a Word Document from Access
    ... Do you have reference to Microsoft Word 11.0 Object Library? ... > Dim objword As Word.Application ... > ' Automation Error - The Server Threw An Exception ...
    (microsoft.public.access.formscoding)