Copiando para layou...
 
Notifications
Clear all

Copiando para layout e imprimindo

5 Posts
3 Usuários
0 Reactions
1,330 Visualizações
(@maggioni)
Posts: 0
New Member
Topic starter
 

Boa tarde, sou nova nesse mundo vba mas tenho me aventurado para solucionar problemas de minha empresa do qual o segmento é Agência Funerária.
Tenho uma userform(formulario) Declaração de Obito que salva é salvo no banco de dados registrodeobito com o seguinte código

totalregistro = Worksheets("REGISTRODEOBITO").UsedRange.Rows.Count + 1
    Worksheets("REGISTRODEOBITO").Select
    'aqui começa a gravação dos dados'
  
       Cells(totalregistro, 1) = Textnregistro
            Cells(totalregistro, 2) = Textdataregistro
         Cells(totalregistro, 3) = Textfalecidoregistro
          Cells(totalregistro, 4) = Cbsexoregistro
                Cells(totalregistro, 5) = Cbcorregistro
                  Cells(totalregistro, 6) = Textprofissaoregistro
                       Cells(totalregistro, 7) = Textnaturalregistro
                       Cells(totalregistro, 8) = Textdatanascregistro
                 Cells(totalregistro, 9) = Textidaderegistro
           Cells(totalregistro, 10) = cbestadocivilregistro
         Cells(totalregistro, 11) = Textendregistro
       Cells(totalregistro, 12) = Textendnregistro
        Cells(totalregistro, 13) = Textcomplregistro
         Cells(totalregistro, 14) = Textbairroregistro
           Cells(totalregistro, 15) = Textcidaderegistro
       Cells(totalregistro, 16) = Cbufregistro
        Cells(totalregistro, 17) = Textrgrneregistro
          Cells(totalregistro, 18) = Textcpfregistro
           Cells(totalregistro, 19) = Cbbenefregistro
         Cells(totalregistro, 20) = Textnbeneregistro
         Cells(totalregistro, 21) = Cbbensregistro
           Cells(totalregistro, 22) = Cbtestamentoregistro
          Cells(totalregistro, 23) = Cbeleitorregistro
          Cells(totalregistro, 24) = Texteleicidaderegistro
          Cells(totalregistro, 25) = Textzonaregistro
          Cells(totalregistro, 26) = Texteleitornregistro
           Cells(totalregistro, 27) = Cbreservistaregistro
            Cells(totalregistro, 28) = Textidentregistro
           Cells(totalregistro, 29) = Textnomedopairegistro
           Cells(totalregistro, 30) = Cbestadocivilpaisregistro
           Cells(totalregistro, 31) = Textnaturalpairegistro
           Cells(totalregistro, 32) = Textnomedamaeregistro
            Cells(totalregistro, 33) = Cbestadocivilmaeregistro
           Cells(totalregistro, 34) = Textnaturalmaeregistro
          Cells(totalregistro, 35) = Textendpaisregistro
         Cells(totalregistro, 36) = Textnpaisregistro
           Cells(totalregistro, 37) = Textbairropaisregistro
           Cells(totalregistro, 38) = Textcidadepaisregistro
           Cells(totalregistro, 39) = CBUFPAIS
             Cells(totalregistro, 40) = Textfilhos1registro
             Cells(totalregistro, 41) = Textfilhosregistro2
            Cells(totalregistro, 42) = Textdataobito
            Cells(totalregistro, 43) = Texthoraobito
           Cells(totalregistro, 44) = Textlocalobito
            Cells(totalregistro, 45) = Textcidadeobito
            Cells(totalregistro, 46) = cbufobito
           Cells(totalregistro, 47) = Textvelorioobito
          Cells(totalregistro, 48) = Textdatasepultamento
           Cells(totalregistro, 49) = Texthorasepultamento
            Cells(totalregistro, 50) = Textcemitérioobito
            Cells(totalregistro, 51) = CBUFCEMITERIO
           Cells(totalregistro, 52) = Textmedico1obito
           Cells(totalregistro, 53) = Textcrm1obito
           Cells(totalregistro, 54) = Textcemitérioobito
           Cells(totalregistro, 55) = Textmedico2obito
            Cells(totalregistro, 56) = Textcrm2obito
            Cells(totalregistro, 57) = NDECLARACAOMEDICO
             Cells(totalregistro, 58) = Textcausa1
              Cells(totalregistro, 59) = Textcausa2
               Cells(totalregistro, 60) = Textcausa3
              Cells(totalregistro, 61) = Textcausa4
             Cells(totalregistro, 62) = Textobs1obito
              Cells(totalregistro, 63) = Textobs2obito
              Cells(totalregistro, 64) = Textdeclaranteobito
               Cells(totalregistro, 65) = Textrnrnedeclarante
               Cells(totalregistro, 66) = Textparentescodeclarante
               Cells(totalregistro, 67) = Texttelefonedeclarante
                  Cells(totalregistro, 68) = Textenddeclarante
                Cells(totalregistro, 69) = Textbairrodeclarante
               Cells(totalregistro, 70) = Textcidadedeclarante
              Cells(totalregistro, 71) = Cbufdeclarante
              Cells(totalregistro, 72) = Textprofissaodeclarante
               Cells(totalregistro, 73) = Textcartorioregistro
               Cells(totalregistro, 74) = Textendcartorio
                Cells(totalregistro, 75) = Textendncartorio
                 Cells(totalregistro, 76) = Texttelefonecartorio
                  Cells(totalregistro, 77) = Cbatendenteregistro

    
    'mensagem de gravação concluida'
MsgBox "Dados salvo com sucesso"
OBIMPRIMIR.SetFocus

Na mesma userform criei um botao de comando imprimir(obimprimir) e gostaria que ao salvar o registro o usuario click em imprimir as textbox sejam copiadas para a plan( formularioimpressao) nas celulas especificadas visualize a impressão do formulario e em seguida faça a impressão.

 
Postado : 19/10/2017 3:13 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Maggioni

Seja bem-vinda ao fórum!

Para facilitar a tua participação, sugiro tomar conhecimento do conteúdo dos links abaixo:
viewtopic.php?f=7&t=16757
viewtopic.php?f=7&t=203
viewtopic.php?f=7&t=7903
viewtopic.php?f=7&t=3841
viewtopic.php?f=7&t=12600
viewtopic.php?f=7&t=3371

[]s
Patropi - Moderador

 
Postado : 19/10/2017 4:45 pm
(@maggioni)
Posts: 0
New Member
Topic starter
 

Obrigada Patropi, li os conteúdos e peço desculpas pelo termo usado!

 
Postado : 19/10/2017 5:27 pm
(@mprudencio)
Posts: 0
New Member
 

O principio é o mesmo se as celulas sao fixas é so substituir do seu codigo

cells(totalregistro,1),value por range ("A1").value

De forma generalizada é isso.

 
Postado : 09/12/2017 11:54 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Supondo que a planilha de impressão seja Plan5 e UserForm1

Private Sub CommandButton1_Click()
Unload Me
Plan5.PrintPreview
UserForm1.Show
End Sub

Assim você visualizará e retornar ao estado inicial. ;)

 
Postado : 13/12/2017 7:57 pm