Hi,
I dont even know where to start on this one. I found this on the net (everything in italics are the authors comments): - Public Function OpenFirstAttachmentAsTempFile(ByRef rstCurrent As DAO.Recordset, ByVal strFieldName As String) As String
-
-
Dim rstChild As DAO.Recordset2
-
Dim fldAttach As DAO.Field2
-
Dim strFilePath As String
-
Dim strTempDir As String
-
-
strTempDir = Environ("Temp") ' Get the Temp directory from the environment variable.
-
If Right(strTempDir, 1) <> "\" Then strTempDir = strTempDir & "\" ' Make sure the path always ends with a backslash.
-
Set rstChild = rstCurrent.Fields(strFieldName).Value ' the .Value for a complex field returns the underlying recordset.
-
strFilePath = strTempDir & rstChild.Fields("FileName").Value ' Append the name of the first (and only) attached file to temp dir.
-
If Dir(strFilePath) <> "" Then ' the file already exists--delete it first.
-
VBA.SetAttr strFilePath, vbNormal ' remove any file attributes (e.g. read-only) that would block the kill command.
-
VBA.Kill strFilePath ' delete the file.
-
End If
-
-
Set fldAttach = rstChild.Fields("FileData") ' The binary data of the file.
-
fldAttach.SaveToFile strFilePath
-
rstChild.Close ' cleanup
-
VBA.Shell "Explorer.exe " & Chr(34) & strFilePath & Chr(34), vbNormalFocus ' Use Windows Explorer to launch the file.
-
-
End Function 'OpenFirstAttachmentAsTempFile
-
Then I wrote this function just to test it in a database that has a Table1 with an Attachment field named "Files" in which I had already placed a file: - Public Function TestOpenFirstAttachmentAsTempFile()
-
Dim dbs As DAO.Database
-
Dim rst As DAO.Recordset
-
-
Const strTable = "Table1"
-
Const strField = "Files" ' Attachment field in Table1
-
-
Set dbs = CurrentDb
-
Set rst = dbs.OpenRecordset(strTable)
-
'rst.MoveNext ' Uncomment this line to go to the 2nd row in the Table.
-
OpenFirstAttachmentAsTempFile rst, strField
-
rst.Close
-
End Function
-
By using the VBA.Shell command with Explorer.exe, the file will be opened just as if you double clicked it from Windows Explorer!
But i would like to take it one step farther and print it with the default printer. Does anybody think that is possible, or even worth doing. Basically i have documents attached (PDF documents), and want them to print out as the last 2 pages of a report (actually printed to a pdf document, if that helps at all).
Again, as i always say "Any help is greatly appreciated".
2 9481
I was wondering if anyone had an answer for this. I can run the code in this post and it works great to open assigned attachments from the table (pdf), but what i want to do also is:
First run the access reports, then either save these Access reports as a pdf or open the pdf attachments per record and create one document as a pdf. Can anyone help me out on this? Thanks so much!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: jasmith |
last post by:
How will Access fair in a year? Two years? .... The new version of
Access seems to service non programmers as a wizard interface to
quickly create databases via a fancy wizard. Furthermore, why would
you even continue to use Access as a backend when you have a much
superior option in SQL express?
What about as a future front-end development tool? Let's get serious.
Microsoft continues to publish numerous articles and videos on how you...
|
by: VoodooFrog |
last post by:
I am trying to run the following code as a simple test of adding an attachment through access 2007:
Dim rsJob As DAO.Recordset2
Dim rsChild As DAO.Recordset2
Dim field As Field2
Set rsJob = Me.Recordset
Set rsChild = rsJob.Fields("attachments").Value
Set field = rsChild.Fields("filedata")
|
by: bloukopkoggelmander |
last post by:
Hi all
I have a bit of a strange problem where I want to set a table field in Access 2007 to an attachment field, but when I follow the Microsoft workmethod, I get no option in Access for attachment. It should be there, but hey, it's not!
Here is the workmethod I am following : http://office.microsoft.com/en-us/access/HA012138521033.aspx?pid=CH100728901033
Does anyone have this same problem, or does anyone know why I might not have...
|
by: nduerr |
last post by:
I have a table with pdf files stored in an attachment data type field
in a 2007 Access File. I would like to run a query that would select
a group out of this table (easy part) then send the pdf file stored in
the attachment field in each of the selected records to a specific e-
mail address as an attachment to the e-mail. The pdf files can be
zipped together or left separately.
First off, Is this possible? I haven't found a lot of...
|
by: amrit1123 |
last post by:
I m working on ms access 2007. and i want to create a table which have a field of datatype attachment through query u .like this (create table tablename (name varchar);). so, how to create a table using query which have a field attachments. so please help me which keywords(datatype) i used to create attachment datatype in a table like we use varchar to create character type field.
or
How to create a attachments field in access table...
| |
by: ProgrammerChicago |
last post by:
Is there any way to upload and download files using the Access 2007
attachment field type in an ASP.NET webpage?
I found this article pertaining to SQL Server 2005 (http://aspnet.
4guysfromrolla.com/articles/120606-1.aspx), but it's a little complex
for me, and it might be better to have some documenting the procedure
with Access -- that is, if it is at all possible.
|
by: Snoopy33 |
last post by:
I have a DB that I developed on access XP (2002) and deployed over a
year ago. No one has had problems printing any of the reports within
the DB until we started loading 2007 on new computers. The access
2007 users cannot print one of the reports. This is maddening since I
cannot duplicate the issue on any computer that runs 2003 or below.
Is there something going on that I'm not seeing? Does anyone have any
suggestions at all on...
|
by: mturner64 |
last post by:
I am developing an application using asp.net where a user can enter first name, last name, donation amount, date, et cetera. After the user enters the information and clicks submit, the information is written/stored into an Access 2007 database, which works well.
I am now wanting to allow a user to upload an image of themselves along with their text information and have that image stored in a field of the Access 2007 database.
I have...
|
by: bkberg05 |
last post by:
Hi - I currently use Access 2003 and have documents stored in an OLE data type field. I want be able to write a query that contains various other data elements from the table plus the OLE field and export these to an excel file. The query itself shows the document in the OLE field, but when I export the spreadsheet to Excel, the field holding the document shows up blank.
Doing research, I saw Access 2007 had a different data type called...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |