Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2013, 10:54 AM
PosseJohn PosseJohn is offline How to Open a Word Document from ACCESS VBA Windows XP How to Open a Word Document from ACCESS VBA Office 2007
Novice
How to Open a Word Document from ACCESS VBA
 
Join Date: Jul 2011
Posts: 20
PosseJohn is on a distinguished road
Default How to Open a Word Document from ACCESS VBA

I need help opening a file from a UserForm which has a command button to open a word document.

I am using Access2003 and Word 2010. Some machines are running XP and others WIN7.



I would like the Document to open, have it showing with either macros already enabled or the prompt to enable them.

I was trying the following, but the WIN7 would open the document as read-only with no apparent way to enable the macros.
Code:
 
Webtarget = "\\fileserver\location\unit\ShiftTurnover\U3TO.docm" 'Create an instance of MS Word Set oApp = CreateObject(Class:="Word.Application") oApp.Visible = True 'Open the Document oApp.Documents.Open FileName:=Webtarget
The word file was previously tagged as a trusted site in WIN7.
Reply With Quote
  #2  
Old 12-05-2013, 06:05 PM
macropod's Avatar
macropod macropod is offline How to Open a Word Document from ACCESS VBA Windows 7 32bit How to Open a Word Document from ACCESS VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It works for me. Do note, though, that if your Word document contains a Document_Open macro, for example, and that requires any user interaction, its interface will only be seen once you switch windows to the Word application. For example:
Code:
Dim wdObj As Object, wdDoc As Object
Set wdObj = CreateObject("Word.Application")
wdObj.Visible = True
wdObj.Activate
Set wdDoc = wdObj.Documents.Open(Webtarget)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-06-2013, 09:53 AM
PosseJohn PosseJohn is offline How to Open a Word Document from ACCESS VBA Windows 7 32bit How to Open a Word Document from ACCESS VBA Office 2010 32bit
Novice
How to Open a Word Document from ACCESS VBA
 
Join Date: Jul 2011
Posts: 20
PosseJohn is on a distinguished road
Default

OK...

When my document opens, it is visible but still LOCKED. The VBA code isn't enabled when the document is opened (the VBA code within the document unprotects the document and performs other functions).

Any further assistance would be appreciated.

Also, the document opens as READ-ONLY.
Reply With Quote
  #4  
Old 12-06-2013, 04:33 PM
macropod's Avatar
macropod macropod is offline How to Open a Word Document from ACCESS VBA Windows 7 32bit How to Open a Word Document from ACCESS VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In my testing, a Document_Open or AutoOpen macro in the opened document will run and, if coded to do so, unprotect the document for editing.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
importing Access data to a Word document WayneCusack Word VBA 2 12-24-2012 12:26 AM
Cant open word document bootable Word 1 01-21-2012 12:46 PM
word cannot open the document esto Word 1 10-03-2009 03:16 AM
Protecting Word Document by restricting access permissions! user Word 0 11-20-2008 01:21 PM
Can I fill in Word document from Access table and/or query? slim_jim_56 Word Tables 0 10-03-2007 01:59 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft