If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
auto filling bookmarks in word2000
I am trying to automate the filling in of bookmarks in a word document
with information in my access table. This is the coding I am using, but something is wrong with it. What happens is I get a dialog box telling me I can only open in read only mode as the file is "in use by another user". SInce it opens only in 'read only' mode, my bookmarks are not filled in and I am not sure if that portion of the function is working either. Could someone help me find the error of my ways please? I am using MSOffice 2000 on a winxp machine. Function SetBookmark() Dim oWrd As Word.Application Dim oDoc As Object ' Start Microsoft Word and open the document. Set oWrd = CreateObject("Word.Application") oWrd.Documents.Open "C:\NMWorkPackage\DirectDepAuthorization.doc" 'Pass the field info to the word bookmark With oWrd.ActiveDocument.Bookmarks .Item("SSN").Range.Text = frmEmpContInfo.SSN End With 'Printout the doc with the bookmarks in place If Not oDoc Is Nothing Then oDoc.PrintOut oDoc.Save = True oDoc.Close End If oWrd.Quit End Function Thanks for your time and help. It is surely appreciated |
#2
|
|||
|
|||
Hi Joanne,
I can't see anything in your code that would cause this, so the first thing is to make certain that there isn't a left-over Word locking file. These can easily get left behind if Word crashes or is forced to close. If you double-click on the Word document in Windows Explorer, does it open normally? If not, delete any temporary files in the same folder. Word usually puts ~ characters in their names; for more information see http://word.mvps.org or the Microsoft knowledgebase. One line in your code that I'd expect to cause a problem is oDoc.Save = True which should just be oDoc.Save On Sat, 04 Sep 2004 22:20:02 GMT, Joanne wrote: I am trying to automate the filling in of bookmarks in a word document with information in my access table. This is the coding I am using, but something is wrong with it. What happens is I get a dialog box telling me I can only open in read only mode as the file is "in use by another user". SInce it opens only in 'read only' mode, my bookmarks are not filled in and I am not sure if that portion of the function is working either. Could someone help me find the error of my ways please? I am using MSOffice 2000 on a winxp machine. Function SetBookmark() Dim oWrd As Word.Application Dim oDoc As Object ' Start Microsoft Word and open the document. Set oWrd = CreateObject("Word.Application") oWrd.Documents.Open "C:\NMWorkPackage\DirectDepAuthorization.doc" 'Pass the field info to the word bookmark With oWrd.ActiveDocument.Bookmarks .Item("SSN").Range.Text = frmEmpContInfo.SSN End With 'Printout the doc with the bookmarks in place If Not oDoc Is Nothing Then oDoc.PrintOut oDoc.Save = True oDoc.Close End If oWrd.Quit End Function Thanks for your time and help. It is surely appreciated -- John Nurick [Microsoft Access MVP] Please respond in the newgroup and not by email. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
auto filling text in word and outlook | Ronald Guillen | General Discussion | 1 | August 28th, 2004 05:59 AM |
Auto fill criteria/questions on filling formulas down | JAnderson | General Discussion | 2 | July 19th, 2004 09:45 PM |
auto save, auto backup | poonam | Worksheet Functions | 1 | July 15th, 2004 03:29 PM |
summing based on auto filter | Art | General Discussion | 2 | June 13th, 2004 04:19 PM |
Auto paragraph number - then remove auto | Legalbits | General Discussion | 2 | May 17th, 2004 08:11 PM |