MoulayKool
Programmer
Hi,
I am not an expert in vba.Can anyone tell how to solve the following error.
I am trying to export an access report to pdf but i am getting this error:
Compile Error
sub or Function Not defined
This line is highlithed: GetRegistryString
Here the whole code:
Private Sub RunReport_Click()
On Error GoTo Err_RunReport
' Folder where PDF file will be written
sPDFPath = "C:\myapp\archive\"
' Save current default printer
sMyDefPrinter = GetRegistryString(HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device")
' Set default printer to PDF Writer
SaveRegistryString HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device", "Acrobat PDFWriter"
sPDFName = "myReport.pdf"
' Setting value for PDFFileName in the registry stops file dialog box from appearing
SaveRegistryString HKEY_CURRENT_USER, "Software\Adobe\Acrobat PDFWriter", "PDFFileName", sPDFPath + sPDFName
' Run the report
DoCmd.OpenReport "myReport", acPreview
Exit_RunReport:
' Restore default printer
SaveRegistryString HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device", sMyDefPrinter
Exit Sub
Err_RunReport:
MsgBox Err.Description
Resume Exit_RunReport
End Sub
thanks in advance
Moulay
I am not an expert in vba.Can anyone tell how to solve the following error.
I am trying to export an access report to pdf but i am getting this error:
Compile Error
sub or Function Not defined
This line is highlithed: GetRegistryString
Here the whole code:
Private Sub RunReport_Click()
On Error GoTo Err_RunReport
' Folder where PDF file will be written
sPDFPath = "C:\myapp\archive\"
' Save current default printer
sMyDefPrinter = GetRegistryString(HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device")
' Set default printer to PDF Writer
SaveRegistryString HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device", "Acrobat PDFWriter"
sPDFName = "myReport.pdf"
' Setting value for PDFFileName in the registry stops file dialog box from appearing
SaveRegistryString HKEY_CURRENT_USER, "Software\Adobe\Acrobat PDFWriter", "PDFFileName", sPDFPath + sPDFName
' Run the report
DoCmd.OpenReport "myReport", acPreview
Exit_RunReport:
' Restore default printer
SaveRegistryString HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device", sMyDefPrinter
Exit Sub
Err_RunReport:
MsgBox Err.Description
Resume Exit_RunReport
End Sub
thanks in advance
Moulay