gravitywell
Beta member
- Messages
- 2
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 (if you know what you're talking about at least lol)
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...
One more thing, there is no reason to tell me to just begin with the actual source address instead of "ThisWorkbook.Path... that's how it was before. I'm trying to create a floating file referance so I can use the file on multiple computers.
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 (if you know what you're talking about at least lol)
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...
One more thing, there is no reason to tell me to just begin with the actual source address instead of "ThisWorkbook.Path... that's how it was before. I'm trying to create a floating file referance so I can use the file on multiple computers.