Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

MS Access froms creating Word Docs

Options
  • 10-06-2009 10:28pm
    #1
    Registered Users Posts: 1,086 ✭✭✭


    Just wondering is it possible to code forms and buttons in forms in MS Access to create word document files from a template?

    I reckon it must be possible, do you have to create macros?


Comments

  • Registered Users Posts: 197 ✭✭cracker


    You can certainly do it using VBA. You just need to enable the MS Word object library and it will give you access to all the methods and properties that you need.
    Open up the vba editor and choose tools -> references and then select the Microsoft Word Object library (version 11 is word 2003 I think). Then start coding. Something like this. The Documents.add method allows you to specify a template.
    Public Sub test()
    
        Dim wordApp As New Word.Application
        
        wordApp.Visible = True
        
        
        
        Dim objDoc As Word.Document
        
        Set objDoc = wordApp.Documents.Add
        
        
        objDoc.Save
        
        objDoc.Close
        
        wordApp.Quit
        
        Set objDoc = Nothing
        Set wordApp = Nothing
        
    End Sub
    


Advertisement