Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images

I am out of ideasand am after some lateral thinking. I have a folder containing images that i would like to make available within a workbook. I dont know if i should simply use a link to the folder or if there is a better way. There are approx 30 images within the folder and the workbook may only require 5-6 of them.

Any ideas??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default External images

"Gav" wrote in message
...
I am out of ideasand am after some lateral thinking. I have a folder

containing images that i would like to make available within a workbook. I
dont know if i should simply use a link to the folder or if there is a
better way. There are approx 30 images within the folder and the workbook
may only require 5-6 of them.

Hi Gav,

To make an informed recommendation on this we would need more
information. Here are some examples of the additional information required
and why it matters in the decision making process:

1) What are the size of these images? - If they are relatively small, the
simplest route may be to simply place them all on a hidden sheet in the
workbook where they would be readily available.

2) How often do these images change? - If they change frequently, placing
them within the workbook is probably not a good idea because an updated set
of images would not propagate to existing workbooks. Sub-question - does it
matter if new images don't propagate to existing workbooks?

3) Will the image path be the same for every user of this workbook? - If
not, you will either need to write the code required for the user to located
the image folder on their system or put all the images in the workbook.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *



  #3   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images

thanks ro

In response, the images are around 100-200KB each, depending. The location would be the same for each user on their local hard drive (my documents). The images would rarely change...it would serve only as a database of images for the user. Any new images would be updated directly into the target folder

This ofcourse is only an idea i had and would be open to alternatives

Cheers!!!!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default External images

Hi Gav,

If that's the case then you should probably leave the images in the
folder and write code to allow the user to select the image they want. I did
forget to ask what exactly you wanted to do with the image, but regardless,
here's some code to get you started. The most complicated part is getting
the path to the My Documents folder on the user's computer. Allowing them to
select an image and stick it on a worksheet is very easy.

Private Const S_OK As Long = 0
Private Const SHGFP_TYPE_CURRENT As Long = 0
Private Const CSIDL_PERSONAL As Long = 5
Private Const MAX_PATH As Long = 256

Private Declare Function SHGetFolderPathA Lib "Shell32.dll" _
(ByVal hWndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwFlags As Long, _
ByVal szPath As String) As Long

Public Sub InsertImage()
Dim szPath As String
Dim vFullName As Variant
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Sheet1.Pictures.Insert CStr(vFullName)
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub

Private Function szGetMyDocsPath() As String
Dim szPath As String
szPath = String$(MAX_PATH, vbNullChar)
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT, _
szPath) = S_OK Then
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar))
End If
End Function

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
thanks rob

In response, the images are around 100-200KB each, depending. The location

would be the same for each user on their local hard drive (my documents).
The images would rarely change...it would serve only as a database of images
for the user. Any new images would be updated directly into the target
folder.

This ofcourse is only an idea i had and would be open to alternatives.

Cheers!!!!



  #5   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images

thanks again bob....before i go any further, i have a query......to ditermine where the image pastes, can i use a heading??

IE: the sheet has certain sub headings like 'machine' and 'roller'. Can i use these headings as the targets in some way. I would like the image to paste into the empty cell beneath the heading. For each heading, the user would select an image

Thanks!!!!!

----- Rob Bovey wrote: ----

Hi Gav

If that's the case then you should probably leave the images in th
folder and write code to allow the user to select the image they want. I di
forget to ask what exactly you wanted to do with the image, but regardless
here's some code to get you started. The most complicated part is gettin
the path to the My Documents folder on the user's computer. Allowing them t
select an image and stick it on a worksheet is very easy

Private Const S_OK As Long =
Private Const SHGFP_TYPE_CURRENT As Long =
Private Const CSIDL_PERSONAL As Long =
Private Const MAX_PATH As Long = 25

Private Declare Function SHGetFolderPathA Lib "Shell32.dll"
(ByVal hWndOwner As Long,
ByVal nFolder As Long,
ByVal hToken As Long,
ByVal dwFlags As Long,
ByVal szPath As String) As Lon

Public Sub InsertImage(
Dim szPath As Strin
Dim vFullName As Varian
szPath = szGetMyDocsPath() & "\
If Len(szPath) 0 The
ChDrive szPat
ChDir szPat
vFullName = Application.GetOpenFilename(
"Image Files (*.jpg),*.jpg", , "Select an Image"
If vFullName < False The
Sheet1.Pictures.Insert CStr(vFullName
End I
Els
MsgBox "My Documents folder not found.
End I
End Su

Private Function szGetMyDocsPath() As Strin
Dim szPath As Strin
szPath = String$(MAX_PATH, vbNullChar
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT,
szPath) = S_OK The
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar)
End I
End Functio

--
Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com

* Please post all replies to this newsgroup
* I delete all unsolicited e-mail responses


"Gav" wrote in messag
..
thanks ro
In response, the images are around 100-200KB each, depending. The locatio

would be the same for each user on their local hard drive (my documents)
The images would rarely change...it would serve only as a database of image
for the user. Any new images would be updated directly into the targe
folder
This ofcourse is only an idea i had and would be open to alternatives
Cheers!!!






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default External images

Hi Gav,

I've made a modification to the code (shown below) that causes the top
left corner of the specified picture to be positioned in the top left corner
of the cell directly below the current selection. So if the user selects the
header cell prior to running the macro it should do what you want.

Private Const S_OK As Long = 0
Private Const SHGFP_TYPE_CURRENT As Long = 0
Private Const CSIDL_PERSONAL As Long = 5
Private Const MAX_PATH As Long = 256

Private Declare Function SHGetFolderPathA Lib "Shell32.dll" _
(ByVal hWndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwFlags As Long, _
ByVal szPath As String) As Long

Public Sub InsertImageBelowRange()
Dim objImage As Picture
Dim rngCell As Range
Dim szPath As String
Dim vFullName As Variant
Set rngCell = Selection.Offset(1, 0)
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Set objImage = Sheet1.Pictures.Insert(CStr(vFullName))
objImage.Top = rngCell.Top
objImage.Left = rngCell.Left
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub

Private Function szGetMyDocsPath() As String
Dim szPath As String
szPath = String$(MAX_PATH, vbNullChar)
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT, _
szPath) = S_OK Then
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar))
End If
End Function

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
thanks again bob....before i go any further, i have a query......to

ditermine where the image pastes, can i use a heading???

IE: the sheet has certain sub headings like 'machine' and 'roller'. Can i

use these headings as the targets in some way. I would like the image to
paste into the empty cell beneath the heading. For each heading, the user
would select an image.

Thanks!!!!!!



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default External images

I bet Rob meant:

szPath = szGetMyDocsPath() & "\"
If Len(szPath) 1 Then

instead of:

szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then


(since Rob appended "\" to szPath, the length would always be larger than 0.)



Rob Bovey wrote:

Hi Gav,

I've made a modification to the code (shown below) that causes the top
left corner of the specified picture to be positioned in the top left corner
of the cell directly below the current selection. So if the user selects the
header cell prior to running the macro it should do what you want.

Private Const S_OK As Long = 0
Private Const SHGFP_TYPE_CURRENT As Long = 0
Private Const CSIDL_PERSONAL As Long = 5
Private Const MAX_PATH As Long = 256

Private Declare Function SHGetFolderPathA Lib "Shell32.dll" _
(ByVal hWndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwFlags As Long, _
ByVal szPath As String) As Long

Public Sub InsertImageBelowRange()
Dim objImage As Picture
Dim rngCell As Range
Dim szPath As String
Dim vFullName As Variant
Set rngCell = Selection.Offset(1, 0)
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Set objImage = Sheet1.Pictures.Insert(CStr(vFullName))
objImage.Top = rngCell.Top
objImage.Left = rngCell.Left
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub

Private Function szGetMyDocsPath() As String
Dim szPath As String
szPath = String$(MAX_PATH, vbNullChar)
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT, _
szPath) = S_OK Then
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar))
End If
End Function

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *

"Gav" wrote in message
...
thanks again bob....before i go any further, i have a query......to

ditermine where the image pastes, can i use a heading???

IE: the sheet has certain sub headings like 'machine' and 'roller'. Can i

use these headings as the targets in some way. I would like the image to
paste into the empty cell beneath the heading. For each heading, the user
would select an image.

Thanks!!!!!!


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images


Gday rob

How do i run this code?? Does will it insert images in the cell beneath my headings?? There are 5 headings in total and each heading may have a correpsonding image

Cheers!!!!
----- Rob Bovey wrote: ----

Hi Gav

I've made a modification to the code (shown below) that causes the to
left corner of the specified picture to be positioned in the top left corne
of the cell directly below the current selection. So if the user selects th
header cell prior to running the macro it should do what you want

Private Const S_OK As Long =
Private Const SHGFP_TYPE_CURRENT As Long =
Private Const CSIDL_PERSONAL As Long =
Private Const MAX_PATH As Long = 25

Private Declare Function SHGetFolderPathA Lib "Shell32.dll"
(ByVal hWndOwner As Long,
ByVal nFolder As Long,
ByVal hToken As Long,
ByVal dwFlags As Long,
ByVal szPath As String) As Lon

Public Sub InsertImageBelowRange(
Dim objImage As Pictur
Dim rngCell As Rang
Dim szPath As Strin
Dim vFullName As Varian
Set rngCell = Selection.Offset(1, 0
szPath = szGetMyDocsPath() & "\
If Len(szPath) 0 The
ChDrive szPat
ChDir szPat
vFullName = Application.GetOpenFilename(
"Image Files (*.jpg),*.jpg", , "Select an Image"
If vFullName < False The
Set objImage = Sheet1.Pictures.Insert(CStr(vFullName)
objImage.Top = rngCell.To
objImage.Left = rngCell.Lef
End I
Els
MsgBox "My Documents folder not found.
End I
End Su

Private Function szGetMyDocsPath() As Strin
Dim szPath As Strin
szPath = String$(MAX_PATH, vbNullChar
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT,
szPath) = S_OK The
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar)
End I
End Functio

--
Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com

* Please post all replies to this newsgroup
* I delete all unsolicited e-mail responses


"Gav" wrote in messag
..
thanks again bob....before i go any further, i have a query......t

ditermine where the image pastes, can i use a heading??
IE: the sheet has certain sub headings like 'machine' and 'roller'. Can

use these headings as the targets in some way. I would like the image t
paste into the empty cell beneath the heading. For each heading, the use
would select an image
Thanks!!!!!


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default External images

Hi Dave,

Yeah, that was exactly what I meant! How'd you know? <g

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Dave Peterson" wrote in message
...
I bet Rob meant:

szPath = szGetMyDocsPath() & "\"
If Len(szPath) 1 Then

instead of:

szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then


(since Rob appended "\" to szPath, the length would always be larger than

0.)


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default External images

Hi Gav,

Select one of the cells and run the code. This will insert the image for
that heading. Select the next setting and run the code again. Continue for
all additional headings. If your headings will always be located in the same
cells you could run the code inside a loop that iterates through all of
those cells

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...

Gday rob,

How do i run this code?? Does will it insert images in the cell beneath my

headings?? There are 5 headings in total and each heading may have a
correpsonding image.

Cheers!!!!!
----- Rob Bovey wrote: -----

Hi Gav,

I've made a modification to the code (shown below) that causes

the top
left corner of the specified picture to be positioned in the top left

corner
of the cell directly below the current selection. So if the user

selects the
header cell prior to running the macro it should do what you want.

Private Const S_OK As Long = 0
Private Const SHGFP_TYPE_CURRENT As Long = 0
Private Const CSIDL_PERSONAL As Long = 5
Private Const MAX_PATH As Long = 256

Private Declare Function SHGetFolderPathA Lib "Shell32.dll" _
(ByVal hWndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwFlags As Long, _
ByVal szPath As String) As Long

Public Sub InsertImageBelowRange()
Dim objImage As Picture
Dim rngCell As Range
Dim szPath As String
Dim vFullName As Variant
Set rngCell = Selection.Offset(1, 0)
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Set objImage = Sheet1.Pictures.Insert(CStr(vFullName))
objImage.Top = rngCell.Top
objImage.Left = rngCell.Left
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub

Private Function szGetMyDocsPath() As String
Dim szPath As String
szPath = String$(MAX_PATH, vbNullChar)
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT, _
szPath) = S_OK

Then
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar))
End If
End Function

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
thanks again bob....before i go any further, i have a query......to

ditermine where the image pastes, can i use a heading???
IE: the sheet has certain sub headings like 'machine' and

'roller'. Can i
use these headings as the targets in some way. I would like the image

to
paste into the empty cell beneath the heading. For each heading, the

user
would select an image.
Thanks!!!!!!






  #11   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images

Gday again.........ok, let me see......i select the cell under the heading, click tools, macro, select 'run' for the code. It brings the my documents window up but when i select an image, nothing occurs.

The images will always remain 1 row under the heading of the section. SO it may be a good idea to loop. How is this done?

PS: if it is easier to see my workbook i am more than happy to share.....sorry but i am a novic

----- Rob Bovey wrote: ----

Hi Gav

Select one of the cells and run the code. This will insert the image fo
that heading. Select the next setting and run the code again. Continue fo
all additional headings. If your headings will always be located in the sam
cells you could run the code inside a loop that iterates through all o
those cell

--
Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com

* Please post all replies to this newsgroup
* I delete all unsolicited e-mail responses


"Gav" wrote in messag
..
Gday rob
How do i run this code?? Does will it insert images in the cell beneath m

headings?? There are 5 headings in total and each heading may have
correpsonding image
Cheers!!!!

----- Rob Bovey wrote: ----
Hi Gav
I've made a modification to the code (shown below) that cause

the to
left corner of the specified picture to be positioned in the top lef

corne
of the cell directly below the current selection. So if the use

selects th
header cell prior to running the macro it should do what you want
Private Const S_OK As Long =

Private Const SHGFP_TYPE_CURRENT As Long =
Private Const CSIDL_PERSONAL As Long =
Private Const MAX_PATH As Long = 25
Private Declare Function SHGetFolderPathA Lib "Shell32.dll"

(ByVal hWndOwner As Long,
ByVal nFolder As Long,
ByVal hToken As Long,
ByVal dwFlags As Long,
ByVal szPath As String) As Lon
Public Sub InsertImageBelowRange(

Dim objImage As Pictur
Dim rngCell As Rang
Dim szPath As Strin
Dim vFullName As Varian
Set rngCell = Selection.Offset(1, 0
szPath = szGetMyDocsPath() & "\
If Len(szPath) 0 The
ChDrive szPat
ChDir szPat
vFullName = Application.GetOpenFilename(
"Image Files (*.jpg),*.jpg", , "Select an Image"
If vFullName < False The
Set objImage = Sheet1.Pictures.Insert(CStr(vFullName)
objImage.Top = rngCell.To
objImage.Left = rngCell.Lef
End I
Els
MsgBox "My Documents folder not found.
End I
End Su
Private Function szGetMyDocsPath() As Strin

Dim szPath As Strin
szPath = String$(MAX_PATH, vbNullChar
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT,
szPath) = S_O

The
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar)
End I
End Functio
--

Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com
* Please post all replies to this newsgroup

* I delete all unsolicited e-mail responses
"Gav" wrote in messag

..
thanks again bob....before i go any further, i have a query......to

ditermine where the image pastes, can i use a heading???
IE: the sheet has certain sub headings like 'machine' and

'roller'. Can i
use these headings as the targets in some way. I would like the image

to
paste into the empty cell beneath the heading. For each heading, the

user
would select an image.
Thanks!!!!!!


  #12   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images

sorry rob, also, is there a way to have a single click event to run through the sequence (headings) rather than run it each time for each heading. The people using this arent what you would say....computer literate....

cheers!!

----- Rob Bovey wrote: ----

Hi Gav

Select one of the cells and run the code. This will insert the image fo
that heading. Select the next setting and run the code again. Continue fo
all additional headings. If your headings will always be located in the sam
cells you could run the code inside a loop that iterates through all o
those cell

--
Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com

* Please post all replies to this newsgroup
* I delete all unsolicited e-mail responses


"Gav" wrote in messag
..
Gday rob
How do i run this code?? Does will it insert images in the cell beneath m

headings?? There are 5 headings in total and each heading may have
correpsonding image
Cheers!!!!

----- Rob Bovey wrote: ----
Hi Gav
I've made a modification to the code (shown below) that cause

the to
left corner of the specified picture to be positioned in the top lef

corne
of the cell directly below the current selection. So if the use

selects th
header cell prior to running the macro it should do what you want
Private Const S_OK As Long =

Private Const SHGFP_TYPE_CURRENT As Long =
Private Const CSIDL_PERSONAL As Long =
Private Const MAX_PATH As Long = 25
Private Declare Function SHGetFolderPathA Lib "Shell32.dll"

(ByVal hWndOwner As Long,
ByVal nFolder As Long,
ByVal hToken As Long,
ByVal dwFlags As Long,
ByVal szPath As String) As Lon
Public Sub InsertImageBelowRange(

Dim objImage As Pictur
Dim rngCell As Rang
Dim szPath As Strin
Dim vFullName As Varian
Set rngCell = Selection.Offset(1, 0
szPath = szGetMyDocsPath() & "\
If Len(szPath) 0 The
ChDrive szPat
ChDir szPat
vFullName = Application.GetOpenFilename(
"Image Files (*.jpg),*.jpg", , "Select an Image"
If vFullName < False The
Set objImage = Sheet1.Pictures.Insert(CStr(vFullName)
objImage.Top = rngCell.To
objImage.Left = rngCell.Lef
End I
Els
MsgBox "My Documents folder not found.
End I
End Su
Private Function szGetMyDocsPath() As Strin

Dim szPath As Strin
szPath = String$(MAX_PATH, vbNullChar
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT,
szPath) = S_O

The
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar)
End I
End Functio
--

Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com
* Please post all replies to this newsgroup

* I delete all unsolicited e-mail responses
"Gav" wrote in messag

..
thanks again bob....before i go any further, i have a query......t

ditermine where the image pastes, can i use a heading??
IE: the sheet has certain sub headings like 'machine' an

'roller'. Can i
use these headings as the targets in some way. I would like the image

to
paste into the empty cell beneath the heading. For each heading, the

user
would select an image.
Thanks!!!!!!


  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default External images

Hi Gav,

<<ok, let me see......i select the cell under the heading, click tools,
macro, select 'run' for the code. It brings the my documents window up but
when i select an image, nothing occurs.

I'm not sure why this would be happening. Are you sure you're clicking
the OK button after you select an image. If so, what operating system and
Excel version are you using?

<<is there a way to have a single click event to run through the sequence
(headings) rather than run it each time for each heading

I assume you mean you want to loop through all of the headings and
assign the pictures all at once? Will the heading cell locations ever
change? If the heading cell locations are fixed it is possible to do this.
If they will be different on different worksheets then the users will have
to select each one and run the code once for each. If they have fixed
locations, what are the cell addresses?

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
Gday again.........ok, let me see......i select the cell under the

heading, click tools, macro, select 'run' for the code. It brings the my
documents window up but when i select an image, nothing occurs.

The images will always remain 1 row under the heading of the section. SO

it may be a good idea to loop. How is this done??

PS: if it is easier to see my workbook i am more than happy to

share.....sorry but i am a novice

----- Rob Bovey wrote: -----

Hi Gav,

Select one of the cells and run the code. This will insert the

image for
that heading. Select the next setting and run the code again.

Continue for
all additional headings. If your headings will always be located in

the same
cells you could run the code inside a loop that iterates through all

of
those cells

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
Gday rob,
How do i run this code?? Does will it insert images in the cell

beneath my
headings?? There are 5 headings in total and each heading may have a
correpsonding image.
Cheers!!!!!

----- Rob Bovey wrote: -----
Hi Gav,
I've made a modification to the code (shown below) that

causes
the top
left corner of the specified picture to be positioned in the

top left
corner
of the cell directly below the current selection. So if the

user
selects the
header cell prior to running the macro it should do what you

want.
Private Const S_OK As Long = 0

Private Const SHGFP_TYPE_CURRENT As Long = 0
Private Const CSIDL_PERSONAL As Long = 5
Private Const MAX_PATH As Long = 256
Private Declare Function SHGetFolderPathA Lib "Shell32.dll" _

(ByVal hWndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwFlags As Long, _
ByVal szPath As String) As Long
Public Sub InsertImageBelowRange()

Dim objImage As Picture
Dim rngCell As Range
Dim szPath As String
Dim vFullName As Variant
Set rngCell = Selection.Offset(1, 0)
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Set objImage =

Sheet1.Pictures.Insert(CStr(vFullName))
objImage.Top = rngCell.Top
objImage.Left = rngCell.Left
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub
Private Function szGetMyDocsPath() As String

Dim szPath As String
szPath = String$(MAX_PATH, vbNullChar)
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&,

SHGFP_TYPE_CURRENT, _
szPath) =

S_OK
Then
szGetMyDocsPath = Left$(szPath, InStr(szPath,

vbNullChar))
End If
End Function
--

Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/
* Please post all replies to this newsgroup *

* I delete all unsolicited e-mail responses *
"Gav" wrote in message

...
thanks again bob....before i go any further, i have a

query......to
ditermine where the image pastes, can i use a heading???
IE: the sheet has certain sub headings like 'machine' and

'roller'. Can i
use these headings as the targets in some way. I would like

the image
to
paste into the empty cell beneath the heading. For each

heading, the
user
would select an image.
Thanks!!!!!!



  #14   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images

Morning Rob,

Thanks for your help, i know this is dragging out. I am running XP and its excel 2002. I keep trying with the same result unfortunately.
Below are the headings. Data is pasted between these headings so the cell locations will shift down. The image should be in the row below the heading

Cheers!!!!


Feeder


Machine


Delivery


PECOM


Rollers


Options AUD$

* Please note that pricing is exclusive of GST







TOTAL INVESTMENT 0 Plus GST




----- Rob Bovey wrote: -----

Hi Gav,

<<ok, let me see......i select the cell under the heading, click tools,
macro, select 'run' for the code. It brings the my documents window up but
when i select an image, nothing occurs.

I'm not sure why this would be happening. Are you sure you're clicking
the OK button after you select an image. If so, what operating system and
Excel version are you using?

<<is there a way to have a single click event to run through the sequence
(headings) rather than run it each time for each heading

I assume you mean you want to loop through all of the headings and
assign the pictures all at once? Will the heading cell locations ever
change? If the heading cell locations are fixed it is possible to do this.
If they will be different on different worksheets then the users will have
to select each one and run the code once for each. If they have fixed
locations, what are the cell addresses?

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
Gday again.........ok, let me see......i select the cell under the

heading, click tools, macro, select 'run' for the code. It brings the my
documents window up but when i select an image, nothing occurs.
The images will always remain 1 row under the heading of the section. SO

it may be a good idea to loop. How is this done??
PS: if it is easier to see my workbook i am more than happy to

share.....sorry but i am a novice
----- Rob Bovey wrote: -----
Hi Gav,
Select one of the cells and run the code. This will insert the

image for
that heading. Select the next setting and run the code again.

Continue for
all additional headings. If your headings will always be located in

the same
cells you could run the code inside a loop that iterates through all

of
those cells
--

Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/
* Please post all replies to this newsgroup *

* I delete all unsolicited e-mail responses *
"Gav" wrote in message

...
Gday rob,
How do i run this code?? Does will it insert images in the cell

beneath my
headings?? There are 5 headings in total and each heading may have a
correpsonding image.
Cheers!!!!!

----- Rob Bovey wrote: -----
Hi Gav,
I've made a modification to the code (shown below) that

causes
the top
left corner of the specified picture to be positioned in the

top left
corner
of the cell directly below the current selection. So if the

user
selects the
header cell prior to running the macro it should do what you

want.
Private Const S_OK As Long = 0

Private Const SHGFP_TYPE_CURRENT As Long = 0
Private Const CSIDL_PERSONAL As Long = 5
Private Const MAX_PATH As Long = 256
Private Declare Function SHGetFolderPathA Lib "Shell32.dll" _

(ByVal hWndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwFlags As Long, _
ByVal szPath As String) As Long
Public Sub InsertImageBelowRange()

Dim objImage As Picture
Dim rngCell As Range
Dim szPath As String
Dim vFullName As Variant
Set rngCell = Selection.Offset(1, 0)
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Set objImage =

Sheet1.Pictures.Insert(CStr(vFullName))
objImage.Top = rngCell.Top
objImage.Left = rngCell.Left
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub
Private Function szGetMyDocsPath() As String

Dim szPath As String
szPath = String$(MAX_PATH, vbNullChar)
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&,

SHGFP_TYPE_CURRENT, _
szPath) =

S_OK
Then
szGetMyDocsPath = Left$(szPath, InStr(szPath,

vbNullChar))
End If
End Function
--

Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/
* Please post all replies to this newsgroup *

* I delete all unsolicited e-mail responses *
"Gav" wrote in message

...
thanks again bob....before i go any further, i have a

query......to
ditermine where the image pastes, can i use a heading???
IE: the sheet has certain sub headings like 'machine' and

'roller'. Can i
use these headings as the targets in some way. I would like

the image
to
paste into the empty cell beneath the heading. For each

heading, the
user
would select an image.
Thanks!!!!!!

  #15   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images

Hi again...sorry but i trialed the code on a new book and it worked. I changed a simple part....the sheet name (!!!)...and it now says object required.......ideas???

As for the other queries, i would like a click event to run through all headings if possible??? Is it possible also to ditermine the size of the image or do i need to save the images in the folder to the size i want???

Cheers!!

----- Rob Bovey wrote: ----

Hi Gav

<<ok, let me see......i select the cell under the heading, click tools
macro, select 'run' for the code. It brings the my documents window up bu
when i select an image, nothing occurs.

I'm not sure why this would be happening. Are you sure you're clickin
the OK button after you select an image. If so, what operating system an
Excel version are you using

<<is there a way to have a single click event to run through the sequenc
(headings) rather than run it each time for each heading

I assume you mean you want to loop through all of the headings an
assign the pictures all at once? Will the heading cell locations eve
change? If the heading cell locations are fixed it is possible to do this
If they will be different on different worksheets then the users will hav
to select each one and run the code once for each. If they have fixe
locations, what are the cell addresses

--
Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com

* Please post all replies to this newsgroup
* I delete all unsolicited e-mail responses


"Gav" wrote in messag
..
Gday again.........ok, let me see......i select the cell under th

heading, click tools, macro, select 'run' for the code. It brings the m
documents window up but when i select an image, nothing occurs
The images will always remain 1 row under the heading of the section. S

it may be a good idea to loop. How is this done?
PS: if it is easier to see my workbook i am more than happy t

share.....sorry but i am a novic
----- Rob Bovey wrote: ----
Hi Gav
Select one of the cells and run the code. This will insert th

image fo
that heading. Select the next setting and run the code again

Continue fo
all additional headings. If your headings will always be located i

the sam
cells you could run the code inside a loop that iterates through al

o
those cell
--

Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com
* Please post all replies to this newsgroup

* I delete all unsolicited e-mail responses
"Gav" wrote in messag

..
Gday rob
How do i run this code?? Does will it insert images in the cel

beneath m
headings?? There are 5 headings in total and each heading may have
correpsonding image
Cheers!!!!

----- Rob Bovey wrote: ----
Hi Gav
I've made a modification to the code (shown below) tha

cause
the to
left corner of the specified picture to be positioned in th

top lef
corne
of the cell directly below the current selection. So if th

use
selects th
header cell prior to running the macro it should do what yo

want
Private Const S_OK As Long =

Private Const SHGFP_TYPE_CURRENT As Long =
Private Const CSIDL_PERSONAL As Long =
Private Const MAX_PATH As Long = 25
Private Declare Function SHGetFolderPathA Lib "Shell32.dll"

(ByVal hWndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwFlags As Long, _
ByVal szPath As String) As Long
Public Sub InsertImageBelowRange()

Dim objImage As Picture
Dim rngCell As Range
Dim szPath As String
Dim vFullName As Variant
Set rngCell = Selection.Offset(1, 0)
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Set objImage =

Sheet1.Pictures.Insert(CStr(vFullName))
objImage.Top = rngCell.Top
objImage.Left = rngCell.Left
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub
Private Function szGetMyDocsPath() As String

Dim szPath As String
szPath = String$(MAX_PATH, vbNullChar)
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&,

SHGFP_TYPE_CURRENT, _
szPath) =

S_OK
Then
szGetMyDocsPath = Left$(szPath, InStr(szPath,

vbNullChar))
End If
End Function
--

Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/
* Please post all replies to this newsgroup *

* I delete all unsolicited e-mail responses *
"Gav" wrote in message

...
thanks again bob....before i go any further, i have a

query......to
ditermine where the image pastes, can i use a heading???
IE: the sheet has certain sub headings like 'machine' and

'roller'. Can i
use these headings as the targets in some way. I would like

the image
to
paste into the empty cell beneath the heading. For each

heading, the
user
would select an image.
Thanks!!!!!!



  #16   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default External images

Hi Gav,

Try this variation on the code I posted previously and let me know if it
works for you.

Private Const S_OK As Long = 0
Private Const SHGFP_TYPE_CURRENT As Long = 0
Private Const CSIDL_PERSONAL As Long = 5
Private Const MAX_PATH As Long = 256

Private Declare Function SHGetFolderPathA Lib "Shell32.dll" _
(ByVal hwndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwFlags As Long, _
ByVal szPath As String) As Long

Public Sub InsertImageBelowRange()
Dim objImage As Picture
Dim rngCell As Range
Dim szPath As String
Dim vFullName As Variant
Set rngCell = Selection.Offset(1, 0)
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 1 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Set objImage = ActiveSheet.Pictures.Insert(CStr(vFullName))
objImage.Top = rngCell.Top
objImage.Left = rngCell.Left
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub

Private Function szGetMyDocsPath() As String
Dim szPath As String
szPath = String$(MAX_PATH, vbNullChar)
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT, _
szPath) = S_OK Then
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar))
End If
End Function

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
Morning Rob,

Thanks for your help, i know this is dragging out. I am running XP and its

excel 2002. I keep trying with the same result unfortunately.
Below are the headings. Data is pasted between these headings so the cell

locations will shift down. The image should be in the row below the heading

Cheers!!!!


Feeder


Machine


Delivery


PECOM


Rollers


Options AUD$

* Please note that pricing is exclusive of GST







TOTAL INVESTMENT 0 Plus GST






  #17   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images

Excellent!! Works fine. Nearly there now!!

2 last points

1. can i have the image actuallyfill a cell....the cell directly beneath the heading rather than have it paste over data (wrap??

2. can i assign a click event that runs through all the headings as you suggested?

Thanks.....thanks....thanks....thanks!!!!!

----- Rob Bovey wrote: ----

Hi Gav

Try this variation on the code I posted previously and let me know if i
works for you

Private Const S_OK As Long =
Private Const SHGFP_TYPE_CURRENT As Long =
Private Const CSIDL_PERSONAL As Long =
Private Const MAX_PATH As Long = 25

Private Declare Function SHGetFolderPathA Lib "Shell32.dll"
(ByVal hwndOwner As Long,
ByVal nFolder As Long,
ByVal hToken As Long,
ByVal dwFlags As Long,
ByVal szPath As String) As Lon

Public Sub InsertImageBelowRange(
Dim objImage As Pictur
Dim rngCell As Rang
Dim szPath As Strin
Dim vFullName As Varian
Set rngCell = Selection.Offset(1, 0
szPath = szGetMyDocsPath() & "\
If Len(szPath) 1 The
ChDrive szPat
ChDir szPat
vFullName = Application.GetOpenFilename(
"Image Files (*.jpg),*.jpg", , "Select an Image"
If vFullName < False The
Set objImage = ActiveSheet.Pictures.Insert(CStr(vFullName)
objImage.Top = rngCell.To
objImage.Left = rngCell.Lef
End I
Els
MsgBox "My Documents folder not found.
End I
End Su

Private Function szGetMyDocsPath() As Strin
Dim szPath As Strin
szPath = String$(MAX_PATH, vbNullChar
If SHGetFolderPathA(0&, CSIDL_PERSONAL, 0&, SHGFP_TYPE_CURRENT,
szPath) = S_OK The
szGetMyDocsPath = Left$(szPath, InStr(szPath, vbNullChar)
End I
End Functio

--
Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com

* Please post all replies to this newsgroup
* I delete all unsolicited e-mail responses


"Gav" wrote in messag
..
Morning Rob
Thanks for your help, i know this is dragging out. I am running XP and it

excel 2002. I keep trying with the same result unfortunately
Below are the headings. Data is pasted between these headings so the cel

locations will shift down. The image should be in the row below the headin
Cheers!!!
Feede
Machin
Deliver
PECO
Roller
Options AUD

* Please note that pricing is exclusive of GS
TOTAL INVESTMENT 0 Plus GS

  #18   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default External images

Hi Gav,

<<1. can i have the image actuallyfill a cell....the cell directly beneath
the heading rather than have it paste over data (wrap??)

I've copied a new version of just the InsertImageBelowRange procedure
that will do this. Replace the previous version of this procedure with the
one shown below. Note this may significantly distort the image depending on
what it looks like at normal size.

<<2. can i assign a click event that runs through all the headings as you
suggested??

I wouldn't use a click event, because that would cause the procedure to
run every time. Better to run it from a button placed on the sheet. At any
rate, yes it can be done as long as the headings are always located in the
same cells on every worksheet the user will ever need to run this for. If
this is the case, you will need to give me the specific cell addresses of
those headings in order for me to write the code.


Public Sub InsertImageBelowRange()
Dim objImage As Picture
Dim rngCell As Range
Dim szPath As String
Dim vFullName As Variant
Set rngCell = Selection.Offset(1, 0)
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 1 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Set objImage = ActiveSheet.Pictures.Insert(CStr(vFullName))
objImage.Top = rngCell.Top
objImage.Left = rngCell.Left
objImage.Height = rngCell.Height
objImage.Width = rngCell.Width
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub


--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
Excellent!! Works fine. Nearly there now!!!

2 last points:

1. can i have the image actuallyfill a cell....the cell directly beneath

the heading rather than have it paste over data (wrap??)

2. can i assign a click event that runs through all the headings as you

suggested??

Thanks.....thanks....thanks....thanks!!!!!!



  #19   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default External images

Psycho, er, psychic.

....or...

Dionne Warwick is one of the voices in my head!



Rob Bovey wrote:

Hi Dave,

Yeah, that was exactly what I meant! How'd you know? <g

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *

"Dave Peterson" wrote in message
...
I bet Rob meant:

szPath = szGetMyDocsPath() & "\"
If Len(szPath) 1 Then

instead of:

szPath = szGetMyDocsPath() & "\"
If Len(szPath) 0 Then


(since Rob appended "\" to szPath, the length would always be larger than

0.)


--

Dave Peterson

  #20   Report Post  
Posted to microsoft.public.excel.programming
gav gav is offline
external usenet poster
 
Posts: 13
Default External images

Hello Rob, getting there. What i was hoping was for the cell to wrap according to the image size...basically accomodate the image???

Unfortunately, the cell location will vary bacause the amount of data that pastes inbetween will vary. Can we use the heading as a target????? Have the image paste 1 row below the heading, column B??

A button to run through all the headings would be great!

Cheers!!!

----- Rob Bovey wrote: ----

Hi Gav

<<1. can i have the image actuallyfill a cell....the cell directly beneat
the heading rather than have it paste over data (wrap??)

I've copied a new version of just the InsertImageBelowRange procedur
that will do this. Replace the previous version of this procedure with th
one shown below. Note this may significantly distort the image depending o
what it looks like at normal size

<<2. can i assign a click event that runs through all the headings as yo
suggested??

I wouldn't use a click event, because that would cause the procedure t
run every time. Better to run it from a button placed on the sheet. At an
rate, yes it can be done as long as the headings are always located in th
same cells on every worksheet the user will ever need to run this for. I
this is the case, you will need to give me the specific cell addresses o
those headings in order for me to write the code


Public Sub InsertImageBelowRange(
Dim objImage As Pictur
Dim rngCell As Rang
Dim szPath As Strin
Dim vFullName As Varian
Set rngCell = Selection.Offset(1, 0
szPath = szGetMyDocsPath() & "\
If Len(szPath) 1 The
ChDrive szPat
ChDir szPat
vFullName = Application.GetOpenFilename(
"Image Files (*.jpg),*.jpg", , "Select an Image"
If vFullName < False The
Set objImage = ActiveSheet.Pictures.Insert(CStr(vFullName)
objImage.Top = rngCell.To
objImage.Left = rngCell.Lef
objImage.Height = rngCell.Heigh
objImage.Width = rngCell.Widt
End I
Els
MsgBox "My Documents folder not found.
End I
End Su


--
Rob Bovey, MCSE, MCSD, Excel MV
Application Professional
http://www.appspro.com

* Please post all replies to this newsgroup
* I delete all unsolicited e-mail responses


"Gav" wrote in messag
..
Excellent!! Works fine. Nearly there now!!
2 last points
1. can i have the image actuallyfill a cell....the cell directly beneat

the heading rather than have it paste over data (wrap??
2. can i assign a click event that runs through all the headings as yo

suggested?
Thanks.....thanks....thanks....thanks!!!!!






  #21   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default External images

Hi Gav,

<<What i was hoping was for the cell to wrap according to the image
size...basically accomodate the image

You can do this for the row height by adding the following line of code
directly below the lines that set the top and left of the image:

rngCell.RowHeight = objImage.Height

Column width is not so simple because it does not have a consistent unit of
measurement. ColumnWidth is measured in terms of the font being used in that
column, so it's difficult to convert to the units of the image width. At any
rate, you can only have one column width for a column and you're stacking
multiple images in the same column, so I'm not so sure how well this would
work anyway.

<<Unfortunately, the cell location will vary bacause the amount of data that
pastes inbetween will vary. Can we use the heading as a target

Yes, that is how the code is constructed now. Unfortunately, it means
that you will have to select each heading cell and run it for each heading.
To add a button to run this code, right-click over the toolbar area and
display the Forms toolbar. The Button object will be on the second row,
right side. Click it and then use your mouse to drag out a button on the
worksheet. The Assign Macro dialog will pop up as soon as you finish. Select
the InsertImageBelowRange macro and click OK. Edit the button text to say
whatever you want. Now when you click the button the procedure will run.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
Hello Rob, getting there. What i was hoping was for the cell to wrap

according to the image size...basically accomodate the image????

Unfortunately, the cell location will vary bacause the amount of data that

pastes inbetween will vary. Can we use the heading as a target????? Have the
image paste 1 row below the heading, column B??

A button to run through all the headings would be great!!

Cheers!!!!

----- Rob Bovey wrote: -----

Hi Gav,

<<1. can i have the image actuallyfill a cell....the cell directly

beneath
the heading rather than have it paste over data (wrap??)

I've copied a new version of just the InsertImageBelowRange

procedure
that will do this. Replace the previous version of this procedure

with the
one shown below. Note this may significantly distort the image

depending on
what it looks like at normal size.

<<2. can i assign a click event that runs through all the headings as

you
suggested??

I wouldn't use a click event, because that would cause the

procedure to
run every time. Better to run it from a button placed on the sheet.

At any
rate, yes it can be done as long as the headings are always located

in the
same cells on every worksheet the user will ever need to run this

for. If
this is the case, you will need to give me the specific cell

addresses of
those headings in order for me to write the code.


Public Sub InsertImageBelowRange()
Dim objImage As Picture
Dim rngCell As Range
Dim szPath As String
Dim vFullName As Variant
Set rngCell = Selection.Offset(1, 0)
szPath = szGetMyDocsPath() & "\"
If Len(szPath) 1 Then
ChDrive szPath
ChDir szPath
vFullName = Application.GetOpenFilename( _
"Image Files (*.jpg),*.jpg", , "Select an Image")
If vFullName < False Then
Set objImage =

ActiveSheet.Pictures.Insert(CStr(vFullName))
objImage.Top = rngCell.Top
objImage.Left = rngCell.Left
objImage.Height = rngCell.Height
objImage.Width = rngCell.Width
End If
Else
MsgBox "My Documents folder not found."
End If
End Sub


--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gav" wrote in message
...
Excellent!! Works fine. Nearly there now!!!
2 last points:
1. can i have the image actuallyfill a cell....the cell directly

beneath
the heading rather than have it paste over data (wrap??)
2. can i assign a click event that runs through all the headings

as you
suggested??
Thanks.....thanks....thanks....thanks!!!!!!






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
External Data Warning Message - I have No External Data in wrkbk Cass_makeitfun[_2_] Excel Discussion (Misc queries) 0 May 12th 10 09:02 PM
Getting External Data based on criteria insde of the external data BigMacExcel Excel Discussion (Misc queries) 0 August 31st 09 06:41 PM
Chart.Export images are shrinking as I export more images Jared Charts and Charting in Excel 3 January 29th 08 03:23 AM
linking images Andrew Excel Discussion (Misc queries) 0 November 29th 06 10:07 PM
Images in Excel Larry E Excel Discussion (Misc queries) 2 February 21st 06 05:28 PM


All times are GMT +1. The time now is 05:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"