Olá Pessoal
Boa Tarde,
venho mais uma vez recorrer a voces para escalecer uma duvida minha.
seguinte..
tenho um relatorio que possui um subformulario de um grafico dinamico.
eu consigo imprimir normalmente em pdf com o codigo abaixo, porem o mesmo sai preto e branco além de sair cortando na pagina, como posso fazer com que o grafico saia colorido e a pagina impressa(pdf) saia no formato paisagem.
qualquer duvida estou a disposição!
muito obrigado a todos!
Codigo:
Function GraficoDinamicoAR()
Dim strsave As String
strsave = "GRAFICO DINAMICO AR.PDF"
'Call the function to print it out
If PrintReportToPDFGrafico("MODIFICAÇÕES - RELATORIO DINAMICO", strsave) = True Then
MsgBox "Relatorio Impresso. " & vbCrLf & vbCrLf & _
Replace(strsave, "\\", "\")
Else
MsgBox "Ocorreu um Erro ao Imprimir o relatorio. Entre em Contato com o Administrador", vbCritical, "PDF Failed"
End If
End Function
_______
Public Function PrintReportToPDFGrafico(strReport As String, strsave As String) As Boolean
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Purpose: Print a report to a PDF file
'
' Inputs: strReport Name of report
' strSave Name of PDF file to create
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Error GoTo ErrHandler
' create the registry entry to set PDF path and filename
WriteRegistryEntry strsave
' print the report - CHECK THAT THE PRINTER NAME IS CORRECT!
Set Application.Printer = Application.Printers("PrintPDF")
DoCmd.OpenReport strReport, acViewNormal, , , acHidden
Application.Printer = Nothing
PrintReportToPDFGrafico = True
ExitHere:
Exit Function
ErrHandler:
MsgBox err.Description
Resume ExitHere
End Function
_____________
Public Function WriteRegistryEntryGrafico(strPDF As String)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Purpose: Create a registry file in order to set the name and path
' of the PDF file
'
' Reference: Concept developed from post at
' http://www.tek-tips.com/viewthread.cfm?qid=1112992
'
' Assumptions: Registry file is created in same folder as current database,
' then deleted once it has been merged into the registry
'
' Inputs: strPDF Name of PDF file to create
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim strPath As String
Dim X
strPath = Left(CurrentDb.name, InStrRev(CurrentDb.name, "\", , vbTextCompare))
' make sure reports folder exists
If Dir(strPath & "Reports\", vbDirectory) = "" Then
MkDir strPath & "Reports\"
End If
' registry key needs "\\" in file path
strPDF = strPath & "Reports\" & strPDF
strPDF = Replace(strPDF, "\", "\\")
' delete the registry file if it exists
On Error Resume Next
Kill strPath & "CreatePDF.reg"
' create the registry file
On Error GoTo ErrHandler
Open strPath & "CreatePDF.reg" For Append As #1
Print #1, "Windows Registry Editor Version 5.00"
Print #1, ""
Print #1, "[HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter]"
Print #1, """PDFFilename""=" & Chr(34) & strPDF & Chr(34)
Close #1
' merge into registry
X = Shell("regedit.exe /s " & strPath & "CreatePDF.reg", vbHide)
ExitHere:
On Error Resume Next
Close #1
Kill strPath & "CreatePDF.reg"
Exit Function
ErrHandler:
MsgBox err.Description
Resume ExitHere
End Function
Boa Tarde,
venho mais uma vez recorrer a voces para escalecer uma duvida minha.
seguinte..
tenho um relatorio que possui um subformulario de um grafico dinamico.
eu consigo imprimir normalmente em pdf com o codigo abaixo, porem o mesmo sai preto e branco além de sair cortando na pagina, como posso fazer com que o grafico saia colorido e a pagina impressa(pdf) saia no formato paisagem.
qualquer duvida estou a disposição!
muito obrigado a todos!
Codigo:
Function GraficoDinamicoAR()
Dim strsave As String
strsave = "GRAFICO DINAMICO AR.PDF"
'Call the function to print it out
If PrintReportToPDFGrafico("MODIFICAÇÕES - RELATORIO DINAMICO", strsave) = True Then
MsgBox "Relatorio Impresso. " & vbCrLf & vbCrLf & _
Replace(strsave, "\\", "\")
Else
MsgBox "Ocorreu um Erro ao Imprimir o relatorio. Entre em Contato com o Administrador", vbCritical, "PDF Failed"
End If
End Function
_______
Public Function PrintReportToPDFGrafico(strReport As String, strsave As String) As Boolean
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Purpose: Print a report to a PDF file
'
' Inputs: strReport Name of report
' strSave Name of PDF file to create
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Error GoTo ErrHandler
' create the registry entry to set PDF path and filename
WriteRegistryEntry strsave
' print the report - CHECK THAT THE PRINTER NAME IS CORRECT!
Set Application.Printer = Application.Printers("PrintPDF")
DoCmd.OpenReport strReport, acViewNormal, , , acHidden
Application.Printer = Nothing
PrintReportToPDFGrafico = True
ExitHere:
Exit Function
ErrHandler:
MsgBox err.Description
Resume ExitHere
End Function
_____________
Public Function WriteRegistryEntryGrafico(strPDF As String)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Purpose: Create a registry file in order to set the name and path
' of the PDF file
'
' Reference: Concept developed from post at
' http://www.tek-tips.com/viewthread.cfm?qid=1112992
'
' Assumptions: Registry file is created in same folder as current database,
' then deleted once it has been merged into the registry
'
' Inputs: strPDF Name of PDF file to create
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim strPath As String
Dim X
strPath = Left(CurrentDb.name, InStrRev(CurrentDb.name, "\", , vbTextCompare))
' make sure reports folder exists
If Dir(strPath & "Reports\", vbDirectory) = "" Then
MkDir strPath & "Reports\"
End If
' registry key needs "\\" in file path
strPDF = strPath & "Reports\" & strPDF
strPDF = Replace(strPDF, "\", "\\")
' delete the registry file if it exists
On Error Resume Next
Kill strPath & "CreatePDF.reg"
' create the registry file
On Error GoTo ErrHandler
Open strPath & "CreatePDF.reg" For Append As #1
Print #1, "Windows Registry Editor Version 5.00"
Print #1, ""
Print #1, "[HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter]"
Print #1, """PDFFilename""=" & Chr(34) & strPDF & Chr(34)
Close #1
' merge into registry
X = Shell("regedit.exe /s " & strPath & "CreatePDF.reg", vbHide)
ExitHere:
On Error Resume Next
Close #1
Kill strPath & "CreatePDF.reg"
Exit Function
ErrHandler:
MsgBox err.Description
Resume ExitHere
End Function