Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert file overlooking file's first character

Status
Not open for further replies.

zapBranigan

Technical User
Jun 29, 2001
3
CA
Hello guys,

Here is my problem:
My first column contains different numerical values.
All numerical value have a matching picture.
The picture's filename is basically composed of the value + a unkown character in front of them.

So I would like to insert the picture file matching the value in column A without having to deal with the first character of the filename.

Here is my code:

If ActiveSheet.Cells(x, 1) > 30000 Then
pic = ActiveSheet.Cells(x, 1).Value
pic = "I:\all sketches\" & pic & ".pcx"
ActiveSheet.Cells(x, 2).Select
ActiveSheet.Pictures.Insert(pic).Select

End If

Can anyone Help me ???

Thank you for your time,

Zap
 
This is some of my code. Change it however you need it, is should explain itself. If there is a problem, declare Num as a long type variable.


Sub test()
Dim Name As String
Dim Pic As String
Dim Num As Integer

Pic = "xPicName.pcx"
Num = Len(Pic)'returns 12 for 12 characters
Num = Num - 1'Sets num=11
Name = Right(Pic, Num)'Sets Name= only the 11 characters on the right side of Pic
Range("A1") = Name 'Outputs the new name to cell A1
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top