Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compile error

Status
Not open for further replies.

MoulayKool

Programmer
Mar 9, 2006
19
US
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
 
You have to find the definition of the GetRegistryString and SaveRegistryString functions from where you copy/pasted your current code ...
 
Maybe this:



You’ll need:
- the Acrobat PDFWriter software on your machine.
- Your own version of the Get/Save registry setting calls below

Note: this is a chopped down version of my real code just to show the salient points. You’ll need to adapt this to your own context.


I don't know what he means by:
- Your own version of the Get/Save registry setting calls below

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top