Solved

Access RunTime Error 430

Posted on 2011-02-12
4
745 Views
Last Modified: 2012-05-11
I have used the attached code with bookmarks to open a word document.  Although previously working with no problems I am now getting the following error:

Run time error '430'
Class does not support Automation or does not support expected interface.  
Any suggestions please?  I have completed system restore and not changed references to my knowledge.

Private Sub cmdLetter_Click()
'Command to export patient information to a word document letter template

On Error GoTo ErrorHandler


    Dim wordDoc As Object            'create variable for Word.Document
    Dim wordApp As Word.Application  'create variable for Word.Application
    Dim wordRange As Object          'Word.Range
    

    create an instance of Word application and a new blank doc
    Set wordApp = New Word.Application

   Move to each bookmark in the document and insert text from the form.
 
      With wordApp
        .Documents.Open Filename:=CurrentProject.path & "\copd discussion.dot"
      
          .ActiveDocument.Bookmarks("PatientTitle").Range.Text = PatientTitle.Value
          .ActiveDocument.Bookmarks("PatientInitial").Range.Text = PatientInitial.Value
          .ActiveDocument.Bookmarks("PatientSurname").Range.Text = PatientSurname.Value
          .ActiveDocument.Bookmarks("PatientAddress1").Range.Text = PatientAddress1.Value
          .ActiveDocument.Bookmarks("PatientTown").Range.Text = PatientTown.Value
          .ActiveDocument.Bookmarks("PatientCounty").Range.Text = PatientCounty.Value
          .ActiveDocument.Bookmarks("PatientPostcode").Range.Text = PatientPostcode.Value
          .ActiveDocument.Bookmarks("PatientTitle1").Range.Text = PatientTitle.Value
          .ActiveDocument.Bookmarks("PatientSurname2").Range.Text = PatientSurname.Value
       
          
          .ActiveDocument.PrintPreview
          .ActiveDocument.SaveAs Filename:=CurrentProject.path & "\" & PatientID.Value & ".doc"
        wordApp.Visible = True
     End With
     DoEvents
     
  
Set wordApp = Nothing
   
    
CleanUpAndExit:
Exit Sub

Error Trap
ErrorHandler:

Call MsgBox("Information is missing.  Please ensure that all fields are completed to create a letter.")
Resume CleanUpAndExit
    
End Sub

Open in new window

0
Comment
Question by:Gwynneth Taylor
  • 2
4 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34879356
:-)
0
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
ID: 34879474
You need to set a doc object to the document you just opened.  Bookmarks belong to documents, not to the Word Application object.

Dim doc As Word.Document

...

Set doc = .Documents.Open (etc.)

Then set up your With ... End With statement for the doc object.
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 34879478
Using ActiveDocument can be chancy, because it might not be the document you think.  That is why it is always a good idea to set a doc object as soon as you create or open a Word document, and then work with the doc object.
0
 

Author Closing Comment

by:Gwynneth Taylor
ID: 34880196
Thank you - I  am up and running again.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now