ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Arguments for a filename (https://www.excelbanter.com/excel-programming/309232-arguments-filename.html)

Michael Smith

Arguments for a filename
 
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!

Don Lloyd

Arguments for a filename
 
Hi Mike,

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

regards,
Don.

"Michael Smith" wrote in message
...
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!




Michael Smith

Arguments for a filename
 
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!

Don Lloyd

Arguments for a filename
 
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

"Michael Smith" wrote in message
...
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!




Michael Smith

Arguments for a filename
 
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!


Don Lloyd

Arguments for a filename
 
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

"Michael Smith" wrote in message
...
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!




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

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