Print Marker
Jan 28, 2008
I need a system which will tick all the boxes to corresponding records when I print a report?
The next time I open the report it would only show the unticked boxes which had yet to be printed.
Thanks for your help,
Richard
View Replies
Nov 9, 2005
The code below does not give me any error. I do get a file save dialog box and i put the file name and a message saying export is done. but in reality there is no pdf file saved under what ever directory i told the system to save...
Public Sub Print2PDF(strReportName As String, Optional strPath As String)
Dim stDocName As String, strFilter As String
Dim Distiller As ACRODISTXLib.PdfDistiller
'InputPSFile - path to existing PS file in c: emp
'OutputPDFFile - path of PDF file to be created in c: emp
'2 lines of code:
'ACRODISTXLib.PdfDistillerClass Distiller=new ACRODISTXLib.PdfDistillerClass();
'Distiller.FileToPDF(InputPSFile, OutputPDFFile,"");
Set Distiller = CreateObject("PdfDistiller.PdfDistiller.1")
Distiller.bSpoolJobs = False
Distiller.bShowWindow = False
ITransform_Transform = False
'Ask for the path if it is not provided
If Trim(strPath) = "" Then
strFilter = ahtAddFilterItem(strFilter, "Adobe PDF Files (*.pdf)", "*.pdf")
strPath = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
End If
'If Distiller.FileToPDF(pFromFile, pToFile, "") Then
'If Distiller.FileToPDF("strReportName.ps", "", "") Then
Distiller.FileToPDF "strReportName.ps", "", ""
'Distiller.FileToPDF OutputDir & "" & ps, OutputDir & "" & pdf, ""
' ITransform_Transform = True
'End If
Set Distiller = Nothing
End Sub
View 1 Replies
View Related
Nov 10, 2005
I used to be able to create PDFs, automatically save them to a file,
and mail them out to people. This was on Access 97 with Windows NT.
We've changed to Windows XP and Access 2003. Doesn't work anymore.
Part of the problem is that the users have no access to the registry
and can only save files on the C: drive to their My Documents folder.
I found this code on the web, but it doesn't work either. The files
continue to print out of my printer instead of making a PDF. I put the
entire code at the bottom, but here is the part I'm calling:
Public Sub SaveReportAsPDF(strReportName As String, Optional strPath As String)
Dim strOldDefault As String
Dim strFilter As String
'Ask for the path if it is not provided
If Trim(strPath) = "" Then
strFilter = ahtAddFilterItem(strFilter, "Adobe PDF Files (*.pdf)", "*.pdf")
strPath = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
End If
'remember old printer
strOldDefault = QueryKey("SoftwareMicrosoftWindowsCurrentVersionWindows", "Device")
'changes to pdf writer
SetKeyValue "SoftwareMicrosoftWindowsCurrentVersionWindows", "Device", "Adobe PDF", REG_SZ
SetKeyValue "SoftwareAdobeAcrobat Distiller", "PDFFilename", strPath, REG_SZ
SetKeyValue "SoftwareAdobeAcrobat Distiller", "bExecViewer", 0, REG_SZ
'Distiller.FileToPDF strReportName
DoCmd.OpenReport strReportName
'put the old printer back to default
SetKeyValue "SoftwareMicrosoftWindowsCurrentVersionWindows", "Device", strOldDefault, REG_SZ
End Sub
The entire code:
' ################################################## #######
Option Compare Database
Option Explicit
Public Const REG_SZ As Long = 1
Public Const REG_DWORD As Long = 4
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const ERROR_NONE = 0
Public Const ERROR_BADDB = 1
Public Const ERROR_BADKEY = 2
Public Const ERROR_CANTOPEN = 3
Public Const ERROR_CANTREAD = 4
Public Const ERROR_CANTWRITE = 5
Public Const ERROR_OUTOFMEMORY = 6
Public Const ERROR_ARENA_TRASHED = 7
Public Const ERROR_ACCESS_DENIED = 8
Public Const ERROR_INVALID_PARAMETERS = 87
Public Const ERROR_NO_MORE_ITEMS = 259
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_ALL_ACCESS = &H3F
Public Const REG_OPTION_NON_VOLATILE = 0
Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As Long
Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias _
"RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions _
As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes _
As Long, phkResult As Long, lpdwDisposition As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
"RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As _
Long) As Long
Declare Function RegQueryValueExString Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
As String, lpcbData As Long) As Long
Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal lpReserved As Long, lpType As Long, lpData As _
Long, lpcbData As Long) As Long
Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
As Long, lpcbData As Long) As Long
Declare Function RegSetValueExString Lib "advapi32.dll" Alias _
"RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As _
String, ByVal cbData As Long) As Long
Declare Function RegSetValueExLong Lib "advapi32.dll" Alias _
"RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, _
ByVal cbData As Long) As Long
Public Function SetValueEx(ByVal hKey As Long, sValueName As String, _
lType As Long, vValue As Variant) As Long
Dim lValue As Long
Dim sValue As String
Select Case lType
Case REG_SZ
sValue = vValue & Chr$(0)
SetValueEx = RegSetValueExString(hKey, sValueName, 0&, _
lType, sValue, Len(sValue))
Case REG_DWORD
lValue = vValue
SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, _
lType, lValue, 4)
End Select
End Function
Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As _
String, vValue As Variant) As Long
Dim cch As Long
Dim lrc As Long
Dim lType As Long
Dim lValue As Long
Dim sValue As String
On Error GoTo QueryValueExError
' Determine the size and type of data to be read
lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch)
If lrc <> ERROR_NONE Then Error 5
Select Case lType
' For strings
Case REG_SZ:
sValue = String(cch, 0)
lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, _
sValue, cch)
If lrc = ERROR_NONE Then
vValue = Left$(sValue, cch - 1)
Else
vValue = Empty
End If
' For DWORDS
Case REG_DWORD:
lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, _
lValue, cch)
If lrc = ERROR_NONE Then vValue = lValue
Case Else
'all other data types not supported
lrc = -1
End Select
QueryValueExExit:
QueryValueEx = lrc
Exit Function
QueryValueExError:
Resume QueryValueExExit
End Function
Public Function CreateNewKey(sNewKeyName As String, lPredefinedKey As Long)
Dim hNewKey As Long ' Handle to the new key
Dim lRetVal As Long ' Result of the RegCreateKeyEx function
lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, vbNullString, REG_OPTION_NON_VOLATILE, _
KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
RegCloseKey (hNewKey)
End Function
Public Function SetKeyValue(sKeyName As String, sValueName As String, vValueSetting As Variant, lValueType As Long)
Dim lRetVal As Long ' Result of the SetValueEx function
Dim hKey As Long ' Handle of open key
' Open the specified key
lRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, KEY_SET_VALUE, hKey)
lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)
RegCloseKey (hKey)
End Function
Public Function QueryKey(sKeyName As String, sValueName As String)
Dim lRetVal As Long ' Result of the API functions
Dim hKey As Long ' Handle of opened key
Dim vValue As Variant ' Setting of queried value
lRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, KEY_QUERY_VALUE, hKey)
lRetVal = QueryValueEx(hKey, sValueName, vValue)
QueryKey = vValue
RegCloseKey (hKey)
End Function
Public Sub SaveReportAsPDF(strReportName As String, Optional strPath As String)
Dim strOldDefault As String
Dim strFilter As String
'Ask for the path if it is not provided
If Trim(strPath) = "" Then
strFilter = ahtAddFilterItem(strFilter, "Adobe PDF Files (*.pdf)", "*.pdf")
strPath = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
End If
'remember old printer
strOldDefault = QueryKey("SoftwareMicrosoftWindowsCurrentVersionWindows", "Device")
'changes to pdf writer
SetKeyValue "SoftwareMicrosoftWindowsCurrentVersionWindows", "Device", "Adobe PDF", REG_SZ
SetKeyValue "SoftwareAdobeAcrobat Distiller", "PDFFilename", strPath, REG_SZ
SetKeyValue "SoftwareAdobeAcrobat Distiller", "bExecViewer", 0, REG_SZ
'Distiller.FileToPDF strReportName
DoCmd.OpenReport strReportName
'put the old printer back to default
SetKeyValue "SoftwareMicrosoftWindowsCurrentVersionWindows", "Device", strOldDefault, REG_SZ
End Sub
View 1 Replies
View Related
Mar 16, 2005
Hi, (sorry to be cross-posting, but I didn't get any response from Modules and VBA)
I've messed something up, I think. But I'm not sure if I messed up VB or some connection in Access.
The Symptoms: I've got a print page with checkboxes that represent other form pages in my db.
The page basically prints ok, except where field information is supposed to be.
Wherever there should be field info, it prints #Name? instead. Each field can't seem to find it's info.
The funny thing is that the information displays correctly in the form onscreen.
Just not when I print.
Basically someone else wrote the the Print code and I've been hacking away to make this code work for 3 new forms (e.g. 3 new checkboxes).
While I'm not terribly familiar with VB, I know my way around script and I'm pretty sure I haven't really messed up that code.
How I got there:
At one point in my building of this thing, every time I went to open the 'print' page, I would get an error and drop into VB.
Well, this was driving me nuts, and at that point I hadn't altered the code. I was just trying to view the print page. So, I cleverly pasted into VB the code from an earlier version of the db. This cleared up the debug error nicely, and I was able to finish the code that would allow me to choose 3 new pages to print. But now it's doing the symptom above.
Any help would be appreciated.
Scott
View 3 Replies
View Related