设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 36634|回复: 152
打印 上一主题 下一主题

[报表] [推荐]老外的+我的改進=直接生成完美的PDF報表

[复制链接]
跳转到指定楼层
1#
发表于 2006-5-27 19:21:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
老外的好東東

http://www.lebans.comeporttopdf.htm

我的改進:



Public Function ConvertReportToPDF( _
Optional RptName As String = "", _
Optional SnapshotName As String = "", _
Optional OutputPDFname As String = "", _
Optional ShowSaveFileDialog As Boolean = False, _
Optional StartPDFViewer As Boolean = True, _
Optional CompressionLevel As Long = 0, _
Optional PasswordOwner As String = "", _
Optional PasswordOpen As String = "", _
Optional PasswordRestrictions As Long = 0, _
Optional PDFNoFontEmbedding As Long = 0, Optional Wherecon As String) As Boolean


' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to display
' the standard windows File Dialog window to select an exisiting Snapshot file
' CompressionLevel - not hooked up yet
' PasswordOwner  - not hooked up yet
' PasswordOpen - not hooked up yet
' PasswordRestrictions - not hooked up yet
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only


Dim s As String
Dim blRet As Boolean
' Let's see if the DynaPDF.DLL is available.
blRet = LoadLib()
If blRet = False Then
    ' Cannot find DynaPDF.dll or StrStorage.dll file
    Exit Function
End If

On Error GoTo ERR_CREATSNAP

Dim strPath  As String
Dim strPathandFileName  As String
Dim strEMFUncompressed As String

Dim sOutFile As String
Dim lngRet As Long

' Init our string buffer
strPath = Space(Pathlen)

'Save the ReportName to a local var
mReportName = RptName

' Let's kill any existing Temp SnapShot file
If Len(mUncompressedSnapFile & vbNullString) > 0 Then
    Kill mUncompressedSnapFile
    mUncompressedSnapFile = ""
End If

' If we have been passed the name of a Snapshot file then
' skip the Snapshot creation process below
If Len(SnapshotName & vbNullString) = 0 Then
      
    ' Make sure we were passed a ReportName
    If Len(RptName & vbNullString) = 0 Then
        ' No valid parameters - FAIL AND EXIT!!
        ConvertReportToPDF = ""
        Exit Function
    End If
        
    ' Get the Systems Temp path
    ' Returns Length of path(num characters in path)
    lngRet = GetTempPath(Pathlen, strPath)
    ' Chop off NULLS and trailing "\"
    strPath = Left(strPath, lngRet) & Chr(0)
   
    ' Now need a unique Filename
    ' locked from a previous aborted attemp.
    ' Needs more work!
    strPathandFileName = GetUniqueFilename(strPath, "SNP" & Chr(0), "snp")
   
    ' Export the selected Report to SnapShot format
<FONT color=#f73809>   DoCmd.Echo False
    DoCmd.OpenReport RptName, acViewPreview, , Wherecon
    Reports(RptName).Visible = False
  
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享分享 分享淘帖 订阅订阅
2#
发表于 2006-5-27 19:34:00 | 只看该作者
  1. Public Function ConvertReportToPDF( _

  2. Optional RptName As String = "", _

  3. Optional SnapshotName As String = "", _

  4. Optional OutputPDFname As String = "", _

  5. Optional ShowSaveFileDialog As Boolean = False, _

  6. Optional StartPDFViewer As Boolean = True, _

  7. Optional CompressionLevel As Long = 0, _

  8. Optional PasswordOwner As String = "", _

  9. Optional PasswordOpen As String = "", _

  10. Optional PasswordRestrictions As Long = 0, _

  11. Optional PDFNoFontEmbedding As Long = 0, Optional Wherecon As String) As Boolean





  12. ' RptName is the name of a report contained within this MDB

  13. ' SnapshotName is the name of an existing Snapshot file

  14. ' OutputPDFname is the name you select for the output PDF file

  15. ' ShowSaveFileDialog is a boolean param to specify whether or not to display

  16. ' the standard windows File Dialog window to select an exisiting Snapshot file

  17. ' CompressionLevel - not hooked up yet

  18. ' PasswordOwner - not hooked up yet

  19. ' PasswordOpen - not hooked up yet

  20. ' PasswordRestrictions - not hooked up yet

  21. ' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the

  22. ' default process of embedding all fonts in the output PDF. If you are

  23. ' using ONLY - any of the standard Windows fonts

  24. ' using ONLY - any of the standard 14 Fonts natively supported by the PDF spec

  25. 'The 14 Standard Fonts

  26. 'All version of Adobe's Acrobat support 14 standard fonts. These fonts are always available

  27. 'independent whether they're embedded or not.

  28. 'Family name PostScript name Style

  29. 'Courier Courier fsNone

  30. 'Courier Courier-Bold fsBold

  31. 'Courier Courier-Oblique fsItalic

  32. 'Courier Courier-BoldOblique fsBold + fsItalic

  33. 'Helvetica Helvetica fsNone

  34. 'Helvetica Helvetica-Bold fsBold

  35. 'Helvetica Helvetica-Oblique fsItalic

  36. 'Helvetica Helvetica-BoldOblique fsBold + fsItalic

  37. 'Times Times-Roman fsNone

  38. 'Times Times-Bold fsBold

  39. 'Times Times-Italic fsItalic

  40. 'Times Times-BoldItalic fsBold + fsItalic

  41. 'Symbol Symbol fsNone, other styles are emulated only

  42. 'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only





  43. Dim s As String

  44. Dim blRet As Boolean

  45. ' Let's see if the DynaPDF.DLL is available.

  46. blRet = LoadLib()

  47. If blRet = False Then

  48. ' Cannot find DynaPDF.dll or StrStorage.dll file

  49. Exit Function

  50. End If



  51. On Error GoTo ERR_CREATSNAP



  52. Dim strPath As String

  53. Dim strPathandFileName As String

  54. Dim strEMFUncompressed As String



  55. Dim sOutFile As String

  56. Dim lngRet As Long



  57. ' Init our string buffer

  58. strPath = Space(Pathlen)



  59. 'Save the ReportName to a local var

  60. mReportName = RptName



  61. ' Let's kill any existing Temp SnapShot file

  62. If Len(mUncompressedSnapFile & vbNullString) > 0 Then

  63. Kill mUncompressedSnapFile

  64. mUncompressedSnapFile = ""

  65. End If



  66. ' If we have been passed the name of a Snapshot file then

  67. ' skip the Snapshot creation process below

  68. If Len(SnapshotName & vbNullString) = 0 Then



  69. ' Make sure we were passed a ReportName

  70. If Len(RptName & vbNullString) = 0 Then

  71. ' No valid parameters - FAIL AND EXIT!!

  72. ConvertReportToPDF = ""

  73. Exit Function

  74. End If



  75. ' Get the Systems Temp path

  76. ' Returns Length of path(num characters in path)

  77. lngRet = GetTempPath(Pathlen, strPath)

  78. ' Chop off NULLS and trailing ""

  79. strPath = Left(strPath, lngRet) & Chr(0)



  80. ' Now need a unique Filename

  81. ' locked from a previous aborted attemp.

  82. ' Needs more work!

  83. strPathandFileName = GetUniqueFilename(strPath, "SNP" & Chr(0), "snp")



  84. ' Export the selected Report to SnapShot format

  85. DoCmd.Echo False

  86. DoCmd.OpenReport RptName, acViewPreview, , Wherecon

  87. Reports(RptName).Visible = False
复制代码
先睹为快!

点击这里给我发消息

3#
发表于 2006-5-27 19:37:00 | 只看该作者
leban的东东都是精品,我也在用这个工具哦. 谢谢改进与分享.拿来就用了
4#
发表于 2006-5-27 19:43:00 | 只看该作者
see
5#
发表于 2006-5-27 20:53:00 | 只看该作者
看看
6#
发表于 2006-5-27 21:01:00 | 只看该作者
能否解释下和使用Acrobat Professional效果有何不同?
7#
发表于 2006-5-27 21:15:00 | 只看该作者
1
8#
发表于 2006-5-27 21:20:00 | 只看该作者
梦里寻他千百回,得来全不费功夫.

谢谢分享
9#
发表于 2006-5-27 22:16:00 | 只看该作者
谢谢
10#
发表于 2006-5-27 22:19:00 | 只看该作者
谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-11-15 01:35 , Processed in 0.098320 second(s), 35 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表