Changing the view of a Word doc from Access

  • Thread starter Thread starter Craig
  • Start date Start date
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
 
On Tue, 13 Jan 2009 19:36:01 -0800, Craig

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

-Tom.
Microsoft Access MVP
 
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
 
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 :)
*
 
Back
Top