Dicas  Excel Macros VBA

Imprime o Userform no Word (ou na impressora)

Pergunta 42:
eu preciso imprimir determinado userform1  (formulário) no aplicativo Word, isto é possível?

Resposta 42:
É possível sim, com esta macro; insira no módulo comum e execute

Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)

Private Sub CommandButton1_Click()
Dim Wrd As Object, WrdDoc As Object

'Copie d'écran de la forme active
keybd_event vbKeySnapshot, 1, 0&, 0&
DoEvents

Set Wrd = CreateObject("Word.Application") 'creation session Word
Wrd.Visible = False 'pour que Word reste masqué pendant l'opération

On Error Resume Next
Set WrdDoc = Wrd.Documents.Add
WrdDoc.PageSetup.Orientation = wdOrientLandscape

Wrd.Selection.PasteSpecial 'colle dans le document Word

With WrdDoc.Shapes(1) 'redimensionnement et positionnement de l'objet imprimé
.Left = 50 'bord gauche
.Top = 50 'bord haut
.Width = 400
End With

WrdDoc.PrintOut 'impression

WrdDoc.Close False 'ferme le document Word sans sauvegarde
WrdDoc.Quit 'ferme l'application Word
End Sub


.