473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Copy image to file

How do i copy images to file which are on form or obutton using vba

i need code please
Oct 22 '09 #1
12 14206
ADezii
8,834 Expert 8TB
@nikhilkajrekar
How are these Images contained within the Form? Are they Embedded or Linked? What Format are these Images in?, etc...
Oct 22 '09 #2
for embaded all types of format
Oct 23 '09 #3
ADezii
8,834 Expert 8TB
@nikhilkajrekar
The Binary Data representing the Image has to be extracted from the OLE Object Field and written to a Stream Object. The data is then saved to a Temporary File in a Temporary Folder. I'll post an Attachment tomorrow that should help you.
Oct 23 '09 #4
Please send me file i havent found any attachement

Thanks
Oct 24 '09 #5
ADezii
8,834 Expert 8TB
Please send me file i havent found any attachement
Patience please, I said that I would send it tomorrow, but I'll post the code instead so that it will be a better learning experience for you. Simply stated, the following code will extract the contents of an OLE Object Field to a Unique File. The Primary Table contains Inventory Images in an OLE Object Field named [oPicture], as well as a Field containing a File Extension (jpg, bmp, doc, etc.) called [sFileExtension], and a a Primary Key Field [InvID] among others. I've intentionally kept the Comments sparse so as not to confuse the issue. Any questions, feel free to ask.
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2. Dim rstBLOB As ADODB.Recordset
  3. Dim mstream As ADODB.Stream
  4. Dim strFullPath As String
  5. Const conTEMP_FOLDER As String = "C:\TEMP\"
  6.  
  7. 'Return a 'Unique, Single Record via the Primary Key ([InvID])
  8. strSQL = "SELECT tblInventoryPics.* FROM tblInventoryPics"
  9. strSQL = strSQL & " WHERE tblInventoryPics.InvID=" & Me![InvID]
  10.  
  11. 'Open an ADO Recordset
  12. Set rstBLOB = New ADODB.Recordset
  13. rstBLOB.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
  14.  
  15. If rstBLOB.RecordCount = 0 Then Exit Sub
  16. rstBLOB.MoveFirst
  17.  
  18. 'Create a Stream Object to contain the Binary Data from the OLE Object Field,
  19. '(adTypeBinary), then Open it
  20. Set mstream = New ADODB.Stream
  21. mstream.Type = adTypeBinary
  22. mstream.Open
  23.  
  24. 'Write the contents of the OLE Object Field to the Stream
  25. mstream.Write rstBLOB.Fields("oPicture").Value
  26.  
  27. 'Save the Stream to a Unique Filename, represented by a combination of the Date,
  28. 'Time, and a File Extension as stored in the Table long with the OLE Object.
  29. mstream.SaveToFile conTEMP_FOLDER & Format(Now(), "mmddyyyy_hhnnss.") & _
  30.                    rstBLOB.Fields("sFileExtension").Value, adSaveCreateOverWrite
  31.  
  32. 'Close the BLOB and set to Nothing before it devours you (LOL)!
  33. rstBLOB.Close
  34. Set rstBLOB = Nothing
Oct 24 '09 #6
NeoPa
32,556 Expert Mod 16PB
@nikhilkajrekar
Please do not be so impatient!

ADezii stated clearly that he intended to post the attachment "tomorrow". It is neither polite nor clever to complain of its absence before 24 hours have even passed. This we see as impatience and, as unpaid volunteers, do not feel that such impatience is appropriate. Please try to show better manners in future.

Furthermore, before posting any question you are expected to attempt to find and work on a solution. When you find a specific problem with your attempt, that is the time to post here requesting assistance with any difficulties you have or about a particular function of the code that you don't know how to achieve. When posting your problem, details of the problem itself and where it's found are the bare minimum information required. The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you.

Administrator.
Oct 25 '09 #7
Thanks above code is working fine
but i have one problem i have some embaded images on my form
how do i get extension of that image file
images my be on button or logo or on image control
Nov 2 '09 #8
ADezii
8,834 Expert 8TB
@nikhilkajrekar
To extract the Path and Extension of an Embedded Image in an Image Control named imgEmbedded on a Form:
Expand|Select|Wrap|Line Numbers
  1. Dim img As Image
  2. Dim strImageExtension As String
  3.  
  4. Set img = Me![imgEmbedded]
  5.  
  6. strImageExtension = Mid$(img.Picture, InStrRev(img.Picture, ".") + 1)
  7.  
  8. Debug.Print "Image Filename: " & img.Picture
  9. Debug.Print "Image Extension: " & strImageExtension
Sample OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. Image Filename: C:\Haz-Mat\Graphics\Inventory\CenturyOVA128.JPG
  2. Image Extension: JPG
Nov 2 '09 #9
Please find the attachment i have added code on form load to copy iamge from button that is on the form but i am not getting image
Attached Files
File Type: zip db.zip (15.5 KB, 541 views)
Nov 11 '09 #10
ADezii
8,834 Expert 8TB
@nikhilkajrekar
Sorry, not running Access 2007.
Nov 11 '09 #11
working fine for image control also for the image on button if image is browsed
i used image which provided by access is it there any solution please
Nov 11 '09 #12
NeoPa
32,556 Expert Mod 16PB
I hope ADezii understands your last post, and why you have not posted a copy of your database in an earlier version, because none of it makes any sense to me.
Nov 11 '09 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Risto Heinonen | last post by:
Hi. I have a web page that has images and text. I can carefully select one image and the on the right of the image and then copy & paste to Word. Is it possible to make javascript do the same:...
2
by: Greg | last post by:
looking for an easy way for users to browse for a file on their local drive, and then have access automatically make a copy of that file (files will most likely be images) and save it under a new...
5
by: AlexCDM | last post by:
Greetings; I'm a (young) .NET developer and I have this problem: I'm building an application (with C#) that creates PDF files. To display a JPEG image within the PDF I need to copy the data from...
2
by: Mad Scientist Jr | last post by:
I have a bitmap (32 pixels high, 8192 pixels wide) that contains 255 images, each 32 pixels wide, that I would like to chop up into individual 32x32 bitmap files. Rather than spending hours in...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
0
by: Kirk | last post by:
I have created an application that copies images I select to two printer que's. The images are either AutoCAD plot files (.PLT) or scanned images (.TIF). My method works well for the PLT files on...
4
by: KraftDiner | last post by:
I'm having trouble getting a copy of and object... (a deep copy) I'm writing a method that creates a mirror image of an object (on screen) In order to do this i need to get a copy of the object...
12
by: mantrid | last post by:
Im trying to move a file but am having luck my code is below. The temp and target paths are valid as they echo correctly. but I cant get the copy() function to work, or the rename() function ...
1
by: Joachim Klassen | last post by:
Hi all, a couple of questions regarding LOAD COPY YES: when does a LOAD COPY YES start to write its backup image ? After LOAD Phase or after BUILD or DELETE phase? What gets backed up - data...
3
by: ukfusion | last post by:
Im trying to get an image upload script to work within a session file.....i can get it to work on a single page without any other script....but i need to have the image upload facility built into a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.