Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access RunTime Error 430

Posted on 2011-02-12
4
Medium Priority
?
767 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
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 …

610 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