Start New Discussion within our Software Development Community

Hey, I dont know much about macros or about scripting, but I've got a project to do for work and I looked up some codes and spliced them togeather to fit my specific purpose.
I'm pulling pictures out of folders and sticking them in an excel file. You'll understand what I mean when you read the script

here's what I have so far:

Private Sub CommandButton17_Click()
Range("A35:K69").Select
Dim subfolder As String
subfolder = Range("A7")
Dim picname As String
picname = Range("B9")
ActiveSheet.Pictures.Insert(ThisWorkbook.Path & ("\" & subfolder & "\" & picname & ".jpg")).Select
Selection.ShapeRange.ScaleWidth 0.93, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.88, msoFalse, msoScaleFromTopLeft
ActiveWindow.SmallScroll Down:=8
End Sub

Pretty simple. "ThisWorkbook.Path gives me the path to the folder I want (the folder my excel file is in), and ("\" & subfolder & "\" & picname & ".jpg") give me the extentions to look into the folder and insert the pick I want. The latter should fit onto the former and make one address, but I'm having trouble with the connection point where the & is located. Any help would be much appreciated.

Also, I would like to create another button to open "subfolder" (whichever is named in the cell) in the browser in a new window, but have no idea how to tackle that task...
.

I can't see anything wrong with your code. What I do however think is raising an error is the fact that the cell string in A7 returned is an invalid folder name i.e. your folder is named MyFolder in A7, but the folder name is maybe ThatFolder...

Another thing to have a look at is whether you have permission to access the folder and manipulate files contained therein....

This article has been dead for over six months. Start a new discussion instead.