PC Review


Reply
Thread Tools Rate Thread

Add a Pictures File Name and Path to a cell ?

 
 
Corey
Guest
Posts: n/a
 
      9th Aug 2007
The folowing code places a Picture into a cell, but i need to add the pictures name and file path to
a cell (Offset(0,8) from where it is placed.
How can i code this? See below CAPITAL TEXT to see where i need it ?

Application.ScreenUpdating = False
Sheets("JSA Procedure").Select
If ActiveCell.Height <> 220.5 Then
MsgBox "Please Select the Large Photo Cell where you require the Photo FIRST.", vbExclamation
Exit Sub
Else
Dim ans As String
ans = InputBox("What is the Photo of, " & vbCrLf & vbCrLf & vbTab & "This or That ?", "....")
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim myPic As Picture
Dim res As Variant
'Const sAddress As String = ActiveCell
Set WB = ActiveWorkbook
res = Application.GetOpenFilename _
("Image Files (*.jpg), *.jpg")
If res = False Then Exit Sub
Set SH = ActiveSheet
Set rng = ActiveCell
Set myPic = SH.Pictures.Insert(res)
With myPic
.Top = rng.Top
.Left = rng.Left
myPic.ShapeRange.LockAspectRatio = msoTrue
' myPic.ShapeRange.Height = 220#
myPic.ShapeRange.Width = 278
myPic.ShapeRange.Rotation = 0#
ActiveCell.Offset(2, 0).Value = ans
ActiveCell.Offset(, 8).Value = WANT PICTURES FILEPATH AND NAME HERE
End With
End If
Application.ScreenUpdating = True


Regards

ctm


 
Reply With Quote
 
 
 
 
=?Utf-8?B?TXVoYW1tZWQgUmFmZWVrIE0=?=
Guest
Posts: n/a
 
      9th Aug 2007
use: ActiveCell.Offset(, 8).Value = res

pls do rate

"Corey" wrote:

> The folowing code places a Picture into a cell, but i need to add the pictures name and file path to
> a cell (Offset(0,8) from where it is placed.
> How can i code this? See below CAPITAL TEXT to see where i need it ?
>
> Application.ScreenUpdating = False
> Sheets("JSA Procedure").Select
> If ActiveCell.Height <> 220.5 Then
> MsgBox "Please Select the Large Photo Cell where you require the Photo FIRST.", vbExclamation
> Exit Sub
> Else
> Dim ans As String
> ans = InputBox("What is the Photo of, " & vbCrLf & vbCrLf & vbTab & "This or That ?", "....")
> Dim WB As Workbook
> Dim SH As Worksheet
> Dim rng As Range
> Dim myPic As Picture
> Dim res As Variant
> 'Const sAddress As String = ActiveCell
> Set WB = ActiveWorkbook
> res = Application.GetOpenFilename _
> ("Image Files (*.jpg), *.jpg")
> If res = False Then Exit Sub
> Set SH = ActiveSheet
> Set rng = ActiveCell
> Set myPic = SH.Pictures.Insert(res)
> With myPic
> .Top = rng.Top
> .Left = rng.Left
> myPic.ShapeRange.LockAspectRatio = msoTrue
> ' myPic.ShapeRange.Height = 220#
> myPic.ShapeRange.Width = 278
> myPic.ShapeRange.Rotation = 0#
> ActiveCell.Offset(2, 0).Value = ans
> ActiveCell.Offset(, 8).Value = WANT PICTURES FILEPATH AND NAME HERE
> End With
> End If
> Application.ScreenUpdating = True
>
>
> Regards
>
> ctm
>
>
>

 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      9th Aug 2007
One way:

Const csTOOSMALL As String = _
"Please Select the Large Photo Cell where" & _
" you require the Photo FIRST."
Const csPROMPT As String = _
"What is the Photo of, " & vbCrLf & vbCrLf & _
vbTab & "This or That ?"
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim picMyPic As Picture
Dim vRes As Variant
Dim sAns As String

Application.ScreenUpdating = False
Set wb = ActiveWorkbook
Set ws = wb.Sheets("JSA Procedure")
ws.Select
If ActiveCell.Height <> 220.5 Then
MsgBox csTOOSMALL, vbExclamation
Exit Sub
Else
sAns = InputBox(csPROMPT, "....")
vRes = Application.GetOpenFilename _
("Image Files (*.jpg), *.jpg")
If vRes = False Then Exit Sub
Set rng = ActiveCell
Set picMyPic = ws.Pictures.Insert(vRes)
With picMyPic
.Top = rng.Top
.Left = rng.Left
.ShapeRange.LockAspectRatio = msoTrue
.ShapeRange.Width = 278
.ShapeRange.Rotation = 0#
End With
rng.Offset(2, 0).Value = sAns
rng.Offset(0, 8).Value = vRes
End If
Application.ScreenUpdating = True


In article <#$(E-Mail Removed)>,
"Corey" <(E-Mail Removed)> wrote:

> The folowing code places a Picture into a cell, but i need to add the
> pictures name and file path to
> a cell (Offset(0,8) from where it is placed.
> How can i code this? See below CAPITAL TEXT to see where i need it ?
>
> Application.ScreenUpdating = False
> Sheets("JSA Procedure").Select
> If ActiveCell.Height <> 220.5 Then
> MsgBox "Please Select the Large Photo Cell where you require the Photo
> FIRST.", vbExclamation
> Exit Sub
> Else
> Dim ans As String
> ans = InputBox("What is the Photo of, " & vbCrLf & vbCrLf & vbTab & "This or
> That ?", "....")
> Dim WB As Workbook
> Dim SH As Worksheet
> Dim rng As Range
> Dim myPic As Picture
> Dim res As Variant
> 'Const sAddress As String = ActiveCell
> Set WB = ActiveWorkbook
> res = Application.GetOpenFilename _
> ("Image Files (*.jpg), *.jpg")
> If res = False Then Exit Sub
> Set SH = ActiveSheet
> Set rng = ActiveCell
> Set myPic = SH.Pictures.Insert(res)
> With myPic
> .Top = rng.Top
> .Left = rng.Left
> myPic.ShapeRange.LockAspectRatio = msoTrue
> ' myPic.ShapeRange.Height = 220#
> myPic.ShapeRange.Width = 278
> myPic.ShapeRange.Rotation = 0#
> ActiveCell.Offset(2, 0).Value = ans
> ActiveCell.Offset(, 8).Value = WANT PICTURES FILEPATH AND NAME
> HERE
> End With
> End If
> Application.ScreenUpdating = True
>
>
> Regards
>
> ctm

 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      9th Aug 2007
Simple as thet hey ?

Thank you.
For some reason the (res) would NOt appear in Cell (offset(,8) but would in Cell.Offset(4,0) ??

Shall do the trick though, thanks Muhammed....

"Muhammed Rafeek M" <(E-Mail Removed)> wrote in message
news:8F11B067-3A9B-4A53-B7ED-(E-Mail Removed)...
use: ActiveCell.Offset(, 8).Value = res

pls do rate

"Corey" wrote:

> The folowing code places a Picture into a cell, but i need to add the pictures name and file path
> to
> a cell (Offset(0,8) from where it is placed.
> How can i code this? See below CAPITAL TEXT to see where i need it ?
>
> Application.ScreenUpdating = False
> Sheets("JSA Procedure").Select
> If ActiveCell.Height <> 220.5 Then
> MsgBox "Please Select the Large Photo Cell where you require the Photo FIRST.", vbExclamation
> Exit Sub
> Else
> Dim ans As String
> ans = InputBox("What is the Photo of, " & vbCrLf & vbCrLf & vbTab & "This or That ?", "....")
> Dim WB As Workbook
> Dim SH As Worksheet
> Dim rng As Range
> Dim myPic As Picture
> Dim res As Variant
> 'Const sAddress As String = ActiveCell
> Set WB = ActiveWorkbook
> res = Application.GetOpenFilename _
> ("Image Files (*.jpg), *.jpg")
> If res = False Then Exit Sub
> Set SH = ActiveSheet
> Set rng = ActiveCell
> Set myPic = SH.Pictures.Insert(res)
> With myPic
> .Top = rng.Top
> .Left = rng.Left
> myPic.ShapeRange.LockAspectRatio = msoTrue
> ' myPic.ShapeRange.Height = 220#
> myPic.ShapeRange.Width = 278
> myPic.ShapeRange.Rotation = 0#
> ActiveCell.Offset(2, 0).Value = ans
> ActiveCell.Offset(, 8).Value = WANT PICTURES FILEPATH AND NAME HERE
> End With
> End If
> Application.ScreenUpdating = True
>
>
> Regards
>
> ctm
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image File Path for Linked Pictures =?Utf-8?B?TGF6emFyb25p?= Microsoft Excel Programming 3 28th Mar 2007 03:44 PM
Error 1324, The file path 'my pictures' contains invalid charactor =?Utf-8?B?RXJpYw==?= Windows XP Photos 2 7th Jun 2005 03:30 PM
Changing the Source file path for inserting pictures? =?Utf-8?B?U2lvdXg=?= Microsoft Word Document Management 3 22nd May 2005 05:13 PM
Error 1324, The file path 'my pictures' contains invalid charactor =?Utf-8?B?RXJpYw==?= Windows XP General 3 2nd Mar 2005 09:43 PM
Error 1324, The file path 'my pictures' contains an invalid charac =?Utf-8?B?RXJpYw==?= Windows XP General 2 1st Mar 2005 02:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:00 AM.