Is there a way to save a report as an image (.JPG, .GIF, .PNG) in Microsoft Access using this code instead of saving it as .SNP)?
Private Sub Command150_Click()
DoCmd.OutputTo acOutputReport, "Playa1", acFormatSNP,
"C:\Users\Tony\Documents\Testo\pretty.snp"
End Sub
I'd like to save it as pretty.jpg
Related
I want users to be able to put the Project folder on any location of their choice. If I use:
Application.FollowHyperlink ("C:\Program Files(x86)\Project\reference.pdf")
The pdf document launches only if the user put the Project folder in the Program Files(x86) folder. Is there a way for access to refer to the current path instead? I have tried the below code with no luck.
Private Sub referencefile_Click()
Application.FollowHyperlink (".\reference.pdf")
End Sub
I have tried:
Application.FollowHyperlink (CurrentProject.Path & "\reference.pdf"),
NewWindow:=True
This works well with txt files but not with pdf files. Any idea?
After a Quick Check and ensuring that my pdf file was not corrupted.
Application.FollowHyperlink (CurrentProject.Path & "\reference.pdf"), NewWindow:=True
The above code works fine as long as the pdf file exits in the same location as the front end. If you have ever thought of eliminating the security warning that access gives when you manually enter a hyperlink to a control button's properties, this code may be a good solution.
I want to display dynamically .pdf files like pictures in a report, it should look like this:
i already tried with webbrowser, but then it doesn't show up in the preview or when i print the report out...
I also tried a ole unbound object, also no success, here the code i had in the Report_Load event:
Dim vPath As String
vPath = GetNewestDocument(Me!artNr)
'Returns path for pdf file, about:blank if there is no file.
If vPath = "about:blank" Then
Me!PDFBrowser.visible = True
Me.PDFBrowser.SourceDoc = vbNullString
Else
With Me.PDFBrowser
.OLETypeAllowed = acOLELinked
.SourceDoc = vPath
.SizeMode = acOLESizeStretch
End With
End If
EDIT:
With "I want to display dynamically ..." i meant to change dynamically pdf's in the Report.
EDIT 2:
I just found out that the type of the OLEunbound object is embedded, but i think this one should be linked as i read in other Forums:
When i try to Change it gives error: "This property can not be changed because it is read-only"
You could get a licensed version of Adobe Acrobat (not Reader) and control it programmatically to capture the images you want.
Alternatively, you could use the VBA Shell Function to call a command-line PDF converter like 2Jpeg to programmatically (and dynamically if necessary) convert the PDF to an image (see this), or even "print" the PDF to an image file using the correct driver (see this).
Once you have an image file, you can easily load the created image to your Access form with VBA, perhaps with this.
Without further information (and answers to my previous questions) I can't offer more suggestions at this point but I hope that helps!
This MSaccess report cuts the bottom lines when printing or exporting to pdf.
There are no 'blank' pages produced.
Both printing and export produce a well formated pdf file when run through the GUI menus.
But, when running with code, say:
DoCmd.RunSavedImportExport "ListPost"
or:
DoCmd.OpenReport "ListPost", acViewReport
DoCmd.OutputTo acOutputReport, "", acFormatPDF, "C:\Program Files (x86)\UDD\ListPost.pdf", , , , acExportQualityPrint
will have the problem.
Ideas??!
On Access 2007, is there a way to display the content of a PDF, even if it is just the first page, on a form? This PDF saved in a table as attachment.
Disclaimer: This answer will only work for PDF files stored outside of your database as separate file. They can be located over a network connection, but I do not know how to access them directly from your database table. This site gives a thorough guide to using the attachments, but doesn't show how to actually display them automatically. It is likely functionality not provided by Access.
You can display anything Internet Explorer can display with a Microsoft Web Browser Control.
Once you've added the control, you can navigate to whatever you want to display during the load or open event of the form.
For example, if the control is called WebBrowser0 then the following would work:
Private Sub Form_Load()
Me.WebBrowser0.Navigate2 "C:\example.pdf" 'Substitute the actual address here.
End Sub
This is an extremely versatile method for displaying other content within Access. You can find more information here.
The only two methods I know of for previewing a PDF (WebBrowswer as suggested by Daniel and the Adobe Active X control) require a file path to be passed to the control.
I recommend extracting the file from the attachment field and saving it to a temporary location such as C:\Documents and Settings\username\AppData. This can be found by using the vba Environ command.
Extracting the file is done with the SaveToFile method in the embedded DAO recordset (which is how attachments are stored in memory).
Example Code
Assume each record has a field called AttachedFile and each record has only one attached PDF. The form is using a WebBrowser control named PreviewBrowser to view the PDF
Private Sub Form_Current()
On Error GoTo ExitSub
Dim FormRS As DAO.Recordset
Set FormRS = Me.Recordset
Dim RecAtt As DAO.Recordset
If (Me.AttachedFile.AttachmentCount > 0) Then
Set RecAtt = FormRS.Fields("AttachedFile").Value
RecAtt.OpenRecordset
Dim Path As String
FilePath = Environ("APPDATA") & "\Preview.pdf"
If (Dir(FilePath) <> "") Then Kill FilePath
RecAtt.Fields("FileData").SaveToFile FilePath
Me.PreviewBrowser.Navigate2 FilePath
End If
ExitSub:
RecAtt.Close
End Sub
Of course the code needs to be a bit more complicated if there are multiple attachments to a given record, but that would be done by manipulating the RecAtt recordset.
developing an application in Access. The access file will be located on a db however when users need to use it, I want them to copy it on there desktop. If they do run it off the G:\ drive (our networked folder), it should give them a message.
So are there Win API that will help me solve this?
I am going to put this code in the Form_Load event of a form.
If you want to prevent the users opening your database from the G:\ drive, you can do a simple check with code like this in your startup form:
Dim strMsg As String
If CurrentProject.Path Like "G:*" Then
strMsg = "Please copy this database file to your " & _
"local disk and open the copy instead of this one."
MsgBox strMsg
Application.Quit
End If
If you also want to prevent them opening the database from a different drive letter mapping or a UNC path, you could add a file such as NotFromHere.txt to the folder where your database file is stored.
Dim strMsg As String
Dim strFilePath
strFilePath = CurrentProject.Path & Chr(92) & "NotFromHere.txt"
If Len(Dir(strFilePath)) > 0 Then
strMsg = "Please copy this database file to your " & _
"local disk and open the copy instead of this one."
MsgBox strMsg
Application.Quit
End If
You can use the FileSystemObject DriveType property
http://msdn.microsoft.com/en-us/library/ea5ht6ax(VS.85).aspx
If you need the desktop folder, you might like to look at:
CreateObject("WScript.Shell").SpecialFolders("Desktop")
You might want to check out the excellent access auto FE updater as an automated way of copying down updates etc
http://autofeupdater.com/
I rolled my own very similar system before I found this one and it does make updating the FE so much easier
I think there's a call that will list the (physically) attached drives on a machine, you could call that and compare the drive specifier on the path the user gave against the list.