-
Re: Como salvar o Nome PDF
Alessandro Furtado Dec 26, 2015 5:21 PM (in response to agnaldo neves)sub PrintReport
'ActiveDocument.Reload
ActiveDocument.PrintDocReport "RP01","Teste"
ActiveDocument.PrintDocReport "RP02","Teste"
Set WSHShell = CreateObject("WScript.Shell")
fln = "S:\BI\TecnoFlex\PDF\myreport.pdf"
RegKey = "HKEY_CURRENT_USER\Software\QlikViewPDF\"
WSHShell.RegWrite RegKey & "BypassSaveAs", 1
WSHShell.RegWrite RegKey & "OutputFile", fln
ActiveDocument.GetApplication.Sleep 2000
WSHShell.RegWrite RegKey & "BypassSaveAs", 0
WSHShell.RegWrite RegKey & "OutputFile", ""
Set WSHShell = nothing
ActiveDocument.GetApplication.Sleep 1000
Set filesys = Nothing
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\QlikView Printing.pdf") then
filesys.MoveFile "C:\QlikView Printing.pdf", "C:\Relatório Gerente.pdf"
End If
ActiveDocument.GetApplication.Sleep 1000
ActiveDocument.Save
'ActiveDocument.GetApplication.Quit
end sub
-
Re: Como salvar o Nome PDF
Alessandro Furtado Dec 26, 2015 5:22 PM (in response to Alessandro Furtado )Precisa somente atualizar o caminho aonde esta sendo gravado o PDF
-
Re: Como salvar o Nome PDF
Alessandro Furtado Dec 26, 2015 5:22 PM (in response to Alessandro Furtado )na macro acima....
-
Re: Como salvar o Nome PDF
agnaldo neves Dec 27, 2015 5:47 AM (in response to Alessandro Furtado )Alessandro,
Como ficou o código:
A unica coisa sentir de diferente é que o nome QlikView Printing_3.pdf, QlikView Printing_4.pdf, gerado pelo PDFCreator.
a)Será que existe como, os dois e-mail abaixo que gerou ele ficarem apenas em um e-mail com dois anexos.
b)Existe como eu trocar o nome QlikView Print? para um nome que eu queira.
filesys.MoveFile "C:\pdf\teste.pdf", "C:\pdf\teste1.pdf" (Parte do código abaixo)
Obrigado,
sub PrintReport
'ActiveDocument.Reload
ActiveDocument.PrintDocReport "RP01","Teste"
ActiveDocument.PrintDocReport "RP02","Teste"
Set WSHShell = CreateObject("WScript.Shell")
fln = "S:\BI\TecnoFlex\PDF\myreport.pdf"
RegKey = "HKEY_CURRENT_USER\Software\QlikViewPDF\"
WSHShell.RegWrite RegKey & "BypassSaveAs", 1
WSHShell.RegWrite RegKey & "OutputFile", fln
ActiveDocument.GetApplication.Sleep 2000
WSHShell.RegWrite RegKey & "BypassSaveAs", 0
WSHShell.RegWrite RegKey & "OutputFile", ""
Set WSHShell = nothing
ActiveDocument.GetApplication.Sleep 1000
Set filesys = Nothing
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\QlikView Printing") then
filesys.MoveFile "C:\pdf\teste.pdf", "C:\pdf\teste1.pdf"
End If
ActiveDocument.GetApplication.Sleep 1000
ActiveDocument.Save
'ActiveDocument.GetApplication.Quit
end sub
1-Salvando o pdf.
2- 02 email gerando, gostaria que gera-se apenas um. com 02 anexos.
3-O nome do anexo de um e-mail.
-
Re: Como salvar o Nome PDF
Alessandro Furtado Dec 27, 2015 11:33 AM (in response to agnaldo neves)Agnaldo,
Primeiro teria que desmarcar a opção de usar somente nomes únicos (esta na linha de cima da seta em vermelho da sua imagem)......Desta forma, o nome nunca sera o mesmo (possivelmente _1 , _2 , _3 esta sendo adicionado....). O nome que vai ser salvo por padrão podes mudar no PDFCreator.
Neste post
Tem a rotina que gera o arquivo, renomeia ele e envia por e-mail. Se você usar o envio do PDFCreator, sera sempre para o(s) mesmo(s) destinatários. Pela macro do post, você pode fazer com que seja gerado 1 e-mail para cada representante por exemplo e ele recebera somente as informações dele....E se quiser, poderá ainda mandar mais anexos juntos, inclusive PDF e XLS se quiser. Basta anexar mais arquivos.....
-
Re: Como salvar o Nome PDF
agnaldo neves Dec 27, 2015 2:13 PM (in response to Alessandro Furtado )Alessandro,
Seu exemplo funcionou perfeitamente.
a)Apenas gostaria de saber como faço para enviar o relatório Teste do email2 - RP02
b)Onde no código do macro eu troco o nome do pdf salvo. Exemplo em vez do Relatório Gerente (Vendas do Dia)
c) Existe como eu anexar, mais pdf por email.
obrigado,
-
Envio PDF por Email.qvw 171.0 K
-
Re: Como salvar o Nome PDF
Alessandro Furtado Dec 28, 2015 1:13 PM (in response to agnaldo neves)Agnaldo, esta funcionando.
Basta colocar server , user e senha do email e alterar a pasta que eu uso (tmp) para a sua (pdf).
-
Envio PDF por Email.qvw 167.2 K
-
-
Re: Como salvar o Nome PDF
Alessandro Furtado Dec 28, 2015 2:53 PM (in response to agnaldo neves)Agnaldo,
segue o modelo com 3 no mesmo email.
Na macro, tem comentado aonde gera cada PDF e aonde renomeia eles. Fica mais facil se tiver que colocar ou tirar algum.
-
Envio PDF por Email.qvw 170.0 K
-
-
Re: Como salvar o Nome PDF
agnaldo neves Jan 5, 2016 2:43 PM (in response to agnaldo neves)Preciso fazer carga no arquivo ao entrar.
Estou usando disparadores.
ActiveDocument.Reload
Preciso Salvar o QVW.
ActiveDocument.Save
Preciso fechar a aplicação ao terminar.
ActiveDocument.GetApplication.Quit
Por favor, aonde eu coloco este 03 comando no código abaixo.
Obrigado
ActiveDocument.Reload
ActiveDocument.Save
ActiveDocument.GetApplication.Quit
sub PrintReport
Set WSHShell = CreateObject("WScript.Shell")
fln = "C:\tmp\myreport.pdf"
RegKey = "HKEY_CURRENT_USER\Software\QlikViewPDF\"
WSHShell.RegWrite RegKey & "BypassSaveAs", 1
WSHShell.RegWrite RegKey & "OutputFile", fln
ActiveDocument.GetApplication.Sleep 2000
WSHShell.RegWrite RegKey & "BypassSaveAs", 0
WSHShell.RegWrite RegKey & "OutputFile", ""
Set WSHShell = nothing
end sub
function GetVariable(varName)
Dim v
set v = ActiveDocument.Variables(varName)
GetVariable = v.GetContent.String
end function
Sub ExecMacro()
'ActiveDocument.Reload
Envio()
'ActiveDocument.Save
'ActiveDocument.GetApplication.Quit
'ActiveDocument.GetApplication.Close
End Sub
Sub Envio()
'Set TabelaEmails = ActiveDocument.Fields("Gerente").GetPossibleValues(1000)
'For contEmail = 0 to TabelaEmails.Count - 1 ' Aqui faz um Laco com o campo "Gerente"......
'ActiveDocument.Fields("Gerente").Select TabelaEmails.Item(contEmail).Text
'===========================================================================================
'Aqui apaga se tiver os arquivos.....
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\tmp\VendasdoDia.pdf") then
filesys.DeleteFile "C:\tmp\VendasdoDia.pdf"
End If
Set filesys = Nothing
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\tmp\Estoque.pdf") then
filesys.DeleteFile "C:\tmp\Estoque.pdf"
End If
Set filesys = Nothing
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\tmp\Financeiro.pdf") then
filesys.DeleteFile "C:\tmp\Financeiro.pdf"
End If
Set filesys = Nothing
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\tmp\Auditoria.pdf") then
filesys.DeleteFile "C:\tmp\Auditoria.pdf"
End If
'===========================================================================================
' Aqui roda o relatorio ID RP01
ActiveDocument.GetApplication.Sleep 2000
Set filesys = Nothing
ActiveDocument.PrintDocReport "RP01", "RP01"
PrintReport()
ActiveDocument.GetApplication.Sleep 3000
' Aqui se existe o PDF, entao renomeia ele.......
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\tmp\QlikView Printing.pdf") then
filesys.MoveFile "C:\tmp\QlikView Printing.pdf", "C:\tmp\VendasdoDia.pdf"
End If
Set filesys = Nothing
ActiveDocument.GetApplication.Sleep 3000
'===========================================================================================
' Aqui roda o relatorio ID RP02
ActiveDocument.PrintDocReport "RP02", "RP02"
PrintReport()
ActiveDocument.GetApplication.Sleep 3000
' Aqui se existe o PDF, entao renomeia ele.......
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\tmp\QlikView Printing.pdf") then
filesys.MoveFile "C:\tmp\QlikView Printing.pdf", "C:\tmp\Estoque.pdf"
End If
Set filesys = Nothing
ActiveDocument.GetApplication.Sleep 3000
'===========================================================================================
' Aqui roda o relatorio ID RP03
ActiveDocument.PrintDocReport "RP03", "RP03"
PrintReport()
ActiveDocument.GetApplication.Sleep 3000
' Aqui se existe o PDF, entao renomeia ele.......
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\tmp\QlikView Printing.pdf") then
filesys.MoveFile "C:\tmp\QlikView Printing.pdf", "C:\tmp\Auditoria.pdf"
End If
Set filesys = Nothing
ActiveDocument.GetApplication.Sleep 3000
'===========================================================================================
' Aqui roda o relatorio ID RP02
ActiveDocument.PrintDocReport "RP04", "RP04"
PrintReport()
ActiveDocument.GetApplication.Sleep 3000
' Aqui se existe o PDF, entao renomeia ele.......
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\tmp\QlikView Printing.pdf") then
filesys.MoveFile "C:\tmp\QlikView Printing.pdf", "C:\tmp\Financeiro.pdf"
End If
Set filesys = Nothing
ActiveDocument.GetApplication.Sleep 3000
' '===========================================================================================
' ' Inicio das configuracoes do EMAIL
Porta = GetVariable("smtpPorta")
Server = GetVariable("smtpServer")
Usuario = GetVariable("smtpUser")
Senha = GetVariable("smtpPWD")
Origem = GetVariable("smtpOrigem")
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
'---------------------------------------------------------------------
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = Server
if len(Usuario) > 0 then
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Usuario
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Senha
else
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0
end if
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = Porta
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
'---------------------------------------------------------------------
End With
'Destinatarios = TabelaEmails.Item(contEmail).Text
Destinatarios = "athenas1200@gmail.com"
objEmail.To = Destinatarios
'objEmail.CC = "nn@mm.com.br"
objEmail.From = "athenas1200@gmail.com"
objEmail.Subject = "Relatórios Gerenciais."
objEmail.HTMLBody = "Relatórios Gerenciais."
'===========================================================================================
'Aqui colocamos os anexos.....
objEmail.AddAttachment "C:\tmp\VendasdoDia.pdf"
objEmail.AddAttachment "C:\tmp\Estoque.pdf"
objEmail.AddAttachment "C:\tmp\Auditoria.pdf"
objEmail.AddAttachment "C:\tmp\Financeiro.pdf"
'===========================================================================================
objEmail.Send
'===========================================================================================
'Aqui apagamos os arquivos pois senao da erro na proxima vez.....
'Next
'ActiveDocument.Fields("Gerente").Clear ' Limpar Filtro por Email
End Sub
-
Re: Como salvar o Nome PDF
Alessandro Furtado Jan 5, 2016 3:02 PM (in response to agnaldo neves)Eles já estão la....
Sub ExecMacro()
'ActiveDocument.Reload
Envio()
'ActiveDocument.Save
'ActiveDocument.GetApplication.Quit
'ActiveDocument.GetApplication.Close
End Sub
basta descomentar....Tirar o ' da frente da linha....
-
Re: Como salvar o Nome PDF
agnaldo neves Jan 5, 2016 3:17 PM (in response to Alessandro Furtado )obrigado vou testar...
-
Re: Como salvar o Nome PDF
agnaldo neves Jan 5, 2016 3:21 PM (in response to agnaldo neves)Alessandro,
Não tinha visto os comandos estavam pronto.
Eu acho que é a katchaça do Ano Novo.
-
-
-
-
-
-
-
-
-
-
-
-
-