Changing the view of a Word doc from Access

C

Craig

When I try to change the look in Word using it does not work using Word VBA.
Set wd = New Word.Application
wd.Visible = False
wd.ActiveWindow.View.Type = 1 'Normal
Set wd = Nothing

TIA

--Craig
 
T

Tom van Stiphout

On Tue, 13 Jan 2009 19:36:01 -0800, Craig

How do you know? You wrote:
wd.Visible = False

-Tom.
Microsoft Access MVP
 
C

Craig

Because I output a report to a word document then I email it as an
attachment. I clear out where the doc should be and run the code. Everything
runs fine except it shows up in the "Reading Layout" view. I need it in
"Normal". It's a simple thing to do manually.

---Craig
 
S

strive4peace

Hi Craig,

you have to save the document before you set wd to nothing... also,
where IS the document? Are you wanting to open a file? Make a new
document?

this is the code you posted in another thread:

'~~~~~~~~ YOUR CODE
Set wd = New Word.Application
wd.Visible = False
Set doc = wd.Documents.Open(sFileName)
doc.Variables("View").Value = "Normal"
doc.Save
Set doc = Nothing
Set wd = Nothing
'~~~~~~~~~~~~~~~

in replacing
doc.Variables("View").Value = "Normal"
with
wd.ActiveWindow.View.Type = 1
you took too much out...

~~~

also, you should do:
doc.close
before
set doc = nothing

the first argument for close is whether or not you want to save
changes... so instead of save and then close, you can do this:

doc.close -1
(-1 = value for wdSaveChanges -- and it is best to use the actual values
instead of constants when you are doing automation to you can use late
binding)

Late Binding in Microsoft Access, by Tony Toews
http://www.granite.ab.ca/access/latebinding.htm


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 

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