ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting a Picture from Folder over cell in 2007 (https://www.excelbanter.com/excel-programming/428807-inserting-picture-folder-over-cell-2007-a.html)

ironhydroxide

Inserting a Picture from Folder over cell in 2007
 


Ron de Bruin

Inserting a Picture from Folder over cell in 2007
 
Maybe you are looking for this to add the picture on top of C3

Sub test()
Dim YourPic As Picture
With ActiveSheet.Range("C3")
Set YourPic = .Parent.Pictures.Insert("C:\Data\Picture1.jpg")
YourPic.Top = .Top
YourPic.Width = .Width
YourPic.Height = .Height
YourPic.Left = .Left
End With
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"ironhydroxide" wrote in message
...



ironhydroxide

Inserting a Picture from Folder over cell in 2007
 
Sorry, yesterday the browser was giving me problems and i could not write an
explaination to my subject.

I have a loop that updates the Filename everytime it loops and it is
different every time. the loop gives me a public declared string of the
filename. (the populate is in a different subfunction as the loop.)

How do i take this string of the file (i know that the filename will be in
the stated folder) and use it for the Address of the picture to be populated.
I was successful once, but then I changed some other code (unrelated code)
and i couldnt get this snippet to work anymore.

Thanks
Ironhydroxide

"Ron de Bruin" wrote:

Maybe you are looking for this to add the picture on top of C3

Sub test()
Dim YourPic As Picture
With ActiveSheet.Range("C3")
Set YourPic = .Parent.Pictures.Insert("C:\Data\Picture1.jpg")
YourPic.Top = .Top
YourPic.Width = .Width
YourPic.Height = .Height
YourPic.Left = .Left
End With
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"ironhydroxide" wrote in message
...




Ron de Bruin

Inserting a Picture from Folder over cell in 2007
 
If you dim the string at the top of the module you can use it in your code

Set YourPic = .Parent.Pictures.Insert(YourVariable)



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"ironhydroxide" wrote in message
...
Sorry, yesterday the browser was giving me problems and i could not write an
explaination to my subject.

I have a loop that updates the Filename everytime it loops and it is
different every time. the loop gives me a public declared string of the
filename. (the populate is in a different subfunction as the loop.)

How do i take this string of the file (i know that the filename will be in
the stated folder) and use it for the Address of the picture to be populated.
I was successful once, but then I changed some other code (unrelated code)
and i couldnt get this snippet to work anymore.

Thanks
Ironhydroxide

"Ron de Bruin" wrote:

Maybe you are looking for this to add the picture on top of C3

Sub test()
Dim YourPic As Picture
With ActiveSheet.Range("C3")
Set YourPic = .Parent.Pictures.Insert("C:\Data\Picture1.jpg")
YourPic.Top = .Top
YourPic.Width = .Width
YourPic.Height = .Height
YourPic.Left = .Left
End With
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"ironhydroxide" wrote in message
...





ironhydroxide

Inserting a Picture from Folder over cell in 2007
 
Thanks I had the problem of not using "Set" Before a Dimensioned YourPic So
that is working Now


I now have the question of how to position the Picture over the cell that i
want. For the most part it is in the correct position but it waviers up and
down a bit covering important info beneath it.


Here is a Snippit of my code

With ActiveSheet.Cells(PopRow, PopCol)
Set yourPic = ActiveSheet.Pictures.Insert(Picstring)
yourPic.Top = Cells(PopRow, PopCol).Top 'Here i expect the picture
to be set alligned with the top of the cell. (apparently it isnt working
correctly or i am having a different problem)
yourPic.Width = Cells(PopRow, PopCol).Width
yourPic.Height = Cells(PopRow, PopCol).Height
yourPic.Left = Cells(PopRow, PopCol).Left 'Here i expect the
picture to be set alligned with the side of the cell. (this seems to be
working perfectly)
End With

Hopefully you can answer this question also.

Ironhydroxide


ironhydroxide

Inserting a Picture from Folder over cell in 2007
 
FOUND IT!

I swapped the yourPic.Top = Cells(PopRow, PopCol).Top from the top to the
bottom of the set of cell moving/sizing commands.

Thanks anyways

"ironhydroxide" wrote:

Thanks I had the problem of not using "Set" Before a Dimensioned YourPic So
that is working Now


I now have the question of how to position the Picture over the cell that i
want. For the most part it is in the correct position but it waviers up and
down a bit covering important info beneath it.


Here is a Snippit of my code

With ActiveSheet.Cells(PopRow, PopCol)
Set yourPic = ActiveSheet.Pictures.Insert(Picstring)
yourPic.Top = Cells(PopRow, PopCol).Top 'Here i expect the picture
to be set alligned with the top of the cell. (apparently it isnt working
correctly or i am having a different problem)
yourPic.Width = Cells(PopRow, PopCol).Width
yourPic.Height = Cells(PopRow, PopCol).Height
yourPic.Left = Cells(PopRow, PopCol).Left 'Here i expect the
picture to be set alligned with the side of the cell. (this seems to be
working perfectly)
End With

Hopefully you can answer this question also.

Ironhydroxide



All times are GMT +1. The time now is 11:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com