Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Document locked for editing error message after save & print
Message
 
 
To
All
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Document locked for editing error message after save & print
Miscellaneous
Thread ID:
00594120
Message ID:
00594120
Views:
75
Hi everyone,
I have a program in Visual Basic that stores data in Micrsoft Access and upon clicking one of my command buttons three Microsoft Word documents get sent to the printer. They are mail merge documents getting their information from Microsoft Access. When the command button is clicked (cmdPrint) and the documents are sent to the printer I want the user to be able to type over the information in the text boxes inputting the new data and click save and then be able to print the Word documents again. However when they do as I have described they get an error message that one of the Microsoft Word documents is locked for editing. They closed Word and Access with the previous records so why is it saying that it is still open and locked for editing by them? Even closing and re-opening the VB program does not help. They have to completely log out of their workstation and log back in to get it to print again without saying that the document is locked. The Word documents are stored on the server.
The following it the code for the cmdPrint button:

Private Sub cmdPrint_Click()
Set wrd = GetObject("", "Word.Application")
With wrd
.ChangeFileOpenDirectory "Drive:\Folder\"
.Documents.Open "WordDocument1.doc"
.ActiveDocument.PrintOut
.Documents.Open "WordDocument2.doc"
.ActiveDocument.PrintOut
.Documents.Open "WordDocument3.doc"
.ActiveDocument.PrintOut
.ActiveWindow.Close
.ActiveWindow.Close
.ActiveWindow.Close
End With
End Sub

===========================================================

The following is the code that I use for the text box information to be saved into MS Access:

Private Sub cmd_save_Click()
Screen.MousePointer = 11
var1 = "save"
resp = MsgBox("Are you sure you want to " & var1, vbYesNo, var1)
If resp = vbYes Then
Adodc1.Recordset.UpdateBatch adAffectCurrent
End If
Screen.MousePointer = 0
deEmployee.Update_FullName
deEmployee.Update_Address
End Sub

===========================================================

The second and third to last lines in the ablve code are for SQL statements that run from the Data Environment. They take the fields like first name and last name and put them together into one field.
Is it MS Word or Access that is caching the records? Is there some code that should go after the documents are printed to clear the records from being locked?

Thanks for your help in advance!
Max
Next
Reply
Map
View

Click here to load this message in the networking platform