1

Topic: How to set a picture from a cell in Excel

I ask the help by operation with a picture. In a cell the way to a picture is written down. For example, "C:\ris1.jpeg". Also there is a button  Image, named Pic.
Essence in that at pushing on , the picture should boot.
Here the button code

strPath = Worksheets (3).Cells (1, 2).Value
Pic1.Picture = strPath

Produces an error
Thankful in advance

2

Re: How to set a picture from a cell in Excel

2111 wrote:

Produces an error

the error text it is necessary to guess? Where there is "a button  Image" too to guess?
And generally, you try to appropriate to a picture a text line, apparently

3

Re: How to set a picture from a cell in Excel

http://www.excelworld.ru/stuff/vba_func … /22-1-0-70

4

Re: How to set a picture from a cell in Excel

Understood. Now a question how to load a picture through dialogue. If to do directly: Image1.Picture = LoadPicture ("c:\\1.jpg") works.
And if so: Image1.Picture = LoadPicture (OpenDialog. Filename) does not work

5

Re: How to set a picture from a cell in Excel

Try instead of a method of arbitrary  both stray keystroke to use textbooks and searchers
https://yandex.ru/search/?text=OpenDialog vba&clid=2207714&lr=213

6

Re: How to set a picture from a cell in Excel

Thanks, with file discovery understood. Now, as to me at button click to "Open" to write down file name in the field FOTO.
Here the procedure code

avFiles = Application. GetOpenFilename ("Files of pictures (*.jpeg *),*.jpeg *", 1, "to Select a file", False)
If avFiles = "" Then Exit Sub
==> FOTO.Value = avFiles ' does not work

the Moderator: we Learn to use tags of design of the code - FAQ

7

Re: How to set a picture from a cell in Excel

2111 wrote:

does not work

Something not so
[spoiler]
: I already hinted above:

Shocker. Pro wrote:

the error text needs to be guessed?

[/spoiler]

8

Re: How to set a picture from a cell in Excel

With this problem later hardly I will understand. While prompt how to solve the following problem. Here the code:

Private Sub CommandButton1_Click ()
avFiles = Application. GetOpenFilename ("Excel files (*.jpg *) ,*.jpg", 1, "to Select Excel files", False)
If VarType (avFiles) = vbBoolean Then Exit Sub
Image1.Picture = LoadPicture (avFiles)
Cells (1, 1).Value = Image1.Picture//Here we write down I so I understand the picture code
Image2.Picture = LoadPicture (Cells (1, 1).Value)//It on mine is wrong. Here how to pull out a picture from a cell and to write down in Image2?
End Sub

9

Re: How to set a picture from a cell in Excel

It, apparently, the pointer.
What for such strange manipulations?

10

Re: How to set a picture from a cell in Excel

In general, the primary goal at me, consists in that through the form on the first sheet, to write down employees in basis on the second sheet. And on the third sheet through  to select on a surname and, according to the selected surname, to show a photo. Here I need to master as to write down a photo from Image in a cell and then from a cell to pull out again in Image

11

Re: How to set a picture from a cell in Excel

Well pointer record in a cell precisely does not help in this case, this number very quickly ceases to concern the picture.
And generally, such things become in Aksesse, instead of in Eksele - absolutely typical task from the textbook.  here the Ex-fur-tree?

12

Re: How to set a picture from a cell in Excel

That's it, under the task it is necessary to make it in . If it was a question about , questions would not be

13

Re: How to set a picture from a cell in Excel

Well then it is necessary to experiment or wait for that answer who with it worked.
For example, macro record shows that the picture on sheet is added so:

Sheets ("List1").Pictures. Insert ("C:\s.jpg")

Probably, it is possible to transfer stupidly it then from collection Pictures in Image1.Picture