Jump to content

BD Access em Word 2007


x_soldier
 Share

Recommended Posts

    Boa tarde,

    Podes fazer isso por VBA no Access.

Sub CreateWordDocument

    Dim wordapp As Word.Application
    Dim STRSQL As String
    Dim Conn as adodb.connection
    Dim RST as adodb.recordset

    Set wordapp = CreateObject("Word.application")

    'Open recordset

    set conn = currentproject.connection 
    set RST = new adodb.recordset
    STRSQL = "SELECT * FROM Tabela;" ' executa a query

    RSt.open strsql,conn,adOpenForwardOnly ,adLockReadOnly 

    'Cria documento Word

    wordapp.Visible = True
        
    With wordapp

        .selection.typetext RST!fieldname 'passa para o word os registos obtidos


    End with
    
    
    set rst = nothing 'limpa a variavel rst
    Set wordapp = nothing

end sub

Cordiais cumprimentos,

Apocsantos

"A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.