?
Solved

Access RunTime Error 430

Posted on 2011-02-12
4
Medium Priority
?
764 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 120

Expert Comment

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

Accepted Solution

by:
Helen Feddema earned 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

771 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