设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[报表] 关于直接将报表生成为PDF文件,谁用过下面这段代码?指导我一下!

[复制链接]
跳转到指定楼层
1#
发表于 2007-9-24 15:28:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
谁用过这段代码直接将报表生成为PDF格式的文件,麻烦教一下(QQ:78937045),或者发个例子,万分感谢!


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

http://www.lebans.com/reporttopdf.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!!
C
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
DoCmd.Echo False
DoCmd.OpenReport RptName, acViewPreview, , Wherecon
Reports(RptName).Visible = False
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2007-9-24 18:57:48 | 只看该作者
.......这个问题....深奥的说.
3#
发表于 2007-9-24 22:58:18 | 只看该作者
没注意你改进什么东东,原代码中如下语句,即为直接将报表生成为PDF文件
ConvertReportToPDF(Me.lstRptName.Value, vbNullString, Me.lstRptName.Value & ".PDF", False)

这个东西说不定啥时候也可以用上,本身生成PDF文件也可以借助其他工具,但象这样加入DLL文件到自己的程序中,也还是比较方便的.
4#
发表于 2007-9-25 07:59:17 | 只看该作者
用PDF打印机最简单
5#
 楼主| 发表于 2007-9-25 12:27:06 | 只看该作者
3楼的兄弟,我还是没看懂,有例子吗?帮我做个样品好吗,另个那个DLL文件哪里有下载
6#
发表于 2007-9-25 12:37:34 | 只看该作者
原帖由 wwwwa 于 2007-9-25 07:59 发表
用PDF打印机最简单


赞同...
7#
发表于 2017-9-17 17:39:04 | 只看该作者
大师们能不能帮我们做个实例,谢谢
8#
发表于 2017-9-20 20:58:07 | 只看该作者
看看
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-3 05:28 , Processed in 0.091913 second(s), 31 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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