Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

MS Access froms creating Word Docs

  • 10-06-2009 09:28PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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