Arguments for a filename

M

Michael Smith

I have a sub that has an arguement for (FILE)...basically if a cell says
MIKE, I want it to open up the file MIKE.BMP. I have created the
arguement for FILE I just cant get it to recognize the path. Help is
greatly appreciated...

Obviously it is struggling on FILE.BMP

ActiveSheet.Pictures.Insert("C:\Documents and Settings\Me\My
Documents\My Pictures\FILE.BMP").Select


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

Don Lloyd

Hi Mike,

It's the path to the Picture that's required.
Try changing FILE.BMP to MIKE.BMP

regards,
Don.
 
M

Michael Smith

Unfortunately that won't work... the folder has pictures of lots of
people and the name of the file is the name of each person. My sub
carries the "NAME" as an argument.I want to be able to run the sub after
names are typed in, and have it return the picture of the person by
Inserting that Pic into the file.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

Don Lloyd

Hi,

Assume that the NAME is "Fred"

Fname="Fred" & ".bmp" or,i f NAME returns "Fred" then
Fname=NAME & ".bmp"

ActiveSheet.Pictures.Insert("C:\Documents and Settings\Me\My
Documents\My Pictures\Fname").Select

Does that make semse ?

regards,
Don
 
M

Michael Smith

I see what you are saying but its still not working for me...here's what
I got so far....thanks again.

Sub GetPic()
Call PicImport("A6", "FRED")
End Sub
Private Sub PicImport(Cell, Name)
If Range(Cell).Text = Name Then
Dim NameWithBMP
NameWithBMP = Name & ".bmp"
ActiveSheet.Pictures.Insert("C:\My Blah\My
Pictures\NameWithBMP").Select
Else: End If

End Sub


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

Don Lloyd

Hi again,

I'm not sure of your procedure for getting the picture. Where is this
Private Sub ?

If the name of the picture is on the activesheet, say in cell "A6", all you
need is the following in a standard module.

Sub GetPicture()
Dim Fname As String
Fname = Range("A6") & ".bmp"
ActiveSheet.Pictures.Insert ("C:\My Blah\My Pictures\NameWithBMP")
End Sub

If the path is correct and the picture is in the file, it will load.
I suggest you get the basic part as above working to start with and then
post back.

Regards,
Don

I see what you are saying but its still not working for me...here's what
I got so far....thanks again.

Sub GetPic()
Call PicImport("A6", "FRED")
End Sub
Private Sub PicImport(Cell, Name)
If Range(Cell).Text = Name Then
Dim NameWithBMP
NameWithBMP = Name & ".bmp"
ActiveSheet.Pictures.Insert("C:\My Blah\My
Pictures\NameWithBMP").Select
Else: End If

End Sub


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Top