Solved

Access RunTime Error 430

Posted on 2011-02-12
4
760 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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 …

705 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