How do i copy images to file which are on form or obutton using vba
i need code please
12 14206 @nikhilkajrekar
How are these Images contained within the Form? Are they Embedded or Linked? What Format are these Images in?, etc...
for embaded all types of format
@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.
Please send me file i havent found any attachement
Thanks
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. - Dim strSQL As String
-
Dim rstBLOB As ADODB.Recordset
-
Dim mstream As ADODB.Stream
-
Dim strFullPath As String
-
Const conTEMP_FOLDER As String = "C:\TEMP\"
-
-
'Return a 'Unique, Single Record via the Primary Key ([InvID])
-
strSQL = "SELECT tblInventoryPics.* FROM tblInventoryPics"
-
strSQL = strSQL & " WHERE tblInventoryPics.InvID=" & Me![InvID]
-
-
'Open an ADO Recordset
-
Set rstBLOB = New ADODB.Recordset
-
rstBLOB.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
-
-
If rstBLOB.RecordCount = 0 Then Exit Sub
-
rstBLOB.MoveFirst
-
-
'Create a Stream Object to contain the Binary Data from the OLE Object Field,
-
'(adTypeBinary), then Open it
-
Set mstream = New ADODB.Stream
-
mstream.Type = adTypeBinary
-
mstream.Open
-
-
'Write the contents of the OLE Object Field to the Stream
-
mstream.Write rstBLOB.Fields("oPicture").Value
-
-
'Save the Stream to a Unique Filename, represented by a combination of the Date,
-
'Time, and a File Extension as stored in the Table long with the OLE Object.
-
mstream.SaveToFile conTEMP_FOLDER & Format(Now(), "mmddyyyy_hhnnss.") & _
-
rstBLOB.Fields("sFileExtension").Value, adSaveCreateOverWrite
-
-
'Close the BLOB and set to Nothing before it devours you (LOL)!
-
rstBLOB.Close
-
Set rstBLOB = Nothing
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.
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
@nikhilkajrekar
To extract the Path and Extension of an Embedded Image in an Image Control named imgEmbedded on a Form: - Dim img As Image
-
Dim strImageExtension As String
-
-
Set img = Me![imgEmbedded]
-
-
strImageExtension = Mid$(img.Picture, InStrRev(img.Picture, ".") + 1)
-
-
Debug.Print "Image Filename: " & img.Picture
-
Debug.Print "Image Extension: " & strImageExtension
Sample OUTPUT: - Image Filename: C:\Haz-Mat\Graphics\Inventory\CenturyOVA128.JPG
-
Image Extension: JPG
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
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
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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:...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
...
|
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...
|
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...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
| |