Consulting

Results 1 to 5 of 5

Thread: Export or copy module excel to word text

  1. #1

    Export or copy module excel to word text

    Como eu posso exportar ou copiar o módulo do excel para texto em word formatado, similar aos posts deste forum? obrigado.
    How I can export or copy the module excel to word formatted text same posts this forum? thanks.

  2. #2
    VBAX Tutor Benzadeus's Avatar
    Joined
    Dec 2008
    Location
    Belo Horizonte, Brazil
    Posts
    271
    Location
    Vá, no editor do VBA, em Ferramentas / Referências e ative "Microsoft Visual Basic for Applications Extensibility X.X" e "Microsoft Word XX.X Object Library", onde X é um número qualquer.

    [vba]Sub EnviaWord()
    Dim oWa As Word.Application
    Dim oWd As Word.Document
    Dim vbP As VBIDE.VBProject
    Dim vbC As VBIDE.VBComponent

    Const strMódulo As String = "Módulo1" '<=== mude aqui conforme desejado

    Set vbP = ActiveWorkbook.VBProject
    Set vbC = ActiveWorkbook.VBProject.VBComponents(strMódulo)
    Set oWa = CreateObject("Word.Application")
    Set oWd = oWa.Documents.Add

    oWa.Visible = True

    oWd.Content.InsertAfter (vbC.CodeModule.Lines(1, vbC.CodeModule.CountOfLines))
    oWd.Content.Font.Name = "Courier New (Ocidental)"
    oWd.Content.Font.Size = 10

    Set vbP = Nothing
    Set vbC = Nothing
    Set oWd = Nothing
    Set oWa = Nothing
    End Sub

    [/vba]

  3. #3
    Obrigado, benzadeus, era isso mesmoque precisava. abração. se precisar de algo estamos ai.

  4. #4
    thank you, I have encountered in the learning journey for you.

  5. #5
    Banned VBAX Newbie
    Joined
    Oct 2011
    Posts
    3
    Location
    I just started to play the game,The future Exchange

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •