Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word locking document

Status
Not open for further replies.

techu4

Technical User
Jun 27, 2005
32
GB
Hi all,

I have a for next loop that has a case select section.

One of the cases opens a word document and populates some form fields.

I keep getting a dialog box stating that the document is locked by me and asks if i want to open it as read only.

When the document is opened it is the only instance of the doument so i cannot understand how it can already be locked.

here is the case select code.

Code:
Select Case StatUs
                          
                    
                        Case "Input", "Sales Capture", "Awaiting Refer Sales Contact", "Awaiting Sales Contact", "Awaiting Quoting", "Sent to Underwriting"
                       smsMessage = "Your recent loan application has been provisionally approved. Call us on 08704 428030, quoting your name & postcode so your loan can be arranged."
                        Call SendSmS
                       Case "Originals Pack Sent"
                       smsMessage = "Your signable documents have been sent out and should be with your in 48 hours. Please call us on 08704 428030 if you do not receive them."
                        Call SendSmS
                        Case "Awaiting Docs"
                       smsMessage = "We have not received your loan documents back. Please complete and return A.S.A.P. Please call us if you have any problems on 08704 428030"
                        Call SendSmS
                        Case "Advance Pack Sent"
                        Set WD = CreateObject("Word.Application")
                        Dim Wdoc As Word.Document
                        
                        On Error GoTo openwRddOc
                        Set Wdoc = WD.Documents.Open(App.Path + "\Documents\dfnocontact.doc")
                        'WD.Active = True
                        WD.Visible = True
                        Pause 7500
                        On Error GoTo sEtFields
                        With Wdoc.Bookmarks
    .Item("Text1").Range.Text = objC.GetField(46)
    .Item("Text2").Range.Text = objC.GetField(55)
    .Item("Text3").Range.Text = objC.GetField(53)
    .Item("Text4").Range.Text = objC.GetField(61)
    .Item("Text5").Range.Text = objC.GetField(60)
    .Item("Text6").Range.Text = objC.GetField(59)
    .Item("Text7").Range.Text = objC.GetField(27)
    .Item("Text8").Range.Text = objC.GetField(30)
    .Item("Text9").Range.Text = objC.GetField(31)
    .Item("Text10").Range.Text = objC.GetField(32)
    
    End With
    On Error GoTo ActiveDoC
    WD.PrintOut True
    Do While WD.BackgroundPrintingStatus <> 0
    Loop
    On Error GoTo closeWrd
    WD.Application.Quit wdDoNotSaveChanges
Pause 2500
Set WD = Nothing
End Select

I hope some one can help on this.

I have search the forum but can't seem to find an answer

thanks in advance.
 
Hi,

I have managed to get round the locking of the document by using a template instead.

What happens now is only the first 2 form fields get populated and the code errors on the 3rd one.

Any ideas please.

Cheers
 
Check that you actually have anything in objC.GetField(53) by putting a STOP (f9) in the VBE and examining the value of each of your objC.GetField(XX) fields.

A,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top