coding question

  • Thread starter atlantis43 via AccessMonster.com
  • Start date
A

atlantis43 via AccessMonster.com

Can someone suggest how, from an access form module which I am using to open
an MSWord document, I can open the .doc in minimized form. Next step would
be to close MSWord.
The coding used to open the Word doc is:
Me![Photo].SourceDoc = "C:\Documents and Settings\WinXP\Desktop\docname.doc"

Is there any API, etc that can be used to the minimize or close the doc when
no longer needed.
Richard
 
L

Lord Kelvan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top