Quick VBA Help Needed
-
I need to set a default file path in VBA that will go to:
\fileserver\drafting\logos\
When this code is ran...
Option Explicit Public Sub ImagePicker() Dim sht As Worksheet, shp As Shape Dim file As String Dim fd As FileDialog Dim t As Single, l As Single, w As Single, h As Single ' get some images Set fd = Application.FileDialog(msoFileDialogFilePicker) With fd .AllowMultiSelect = False With .Filters .Clear .Add "Images", "*.ani;*.bmp;*.gif;*.ico;*.jpe;*.jpeg;*.jpg;*.pcx;*.png;*.psd;*.tga;*.tif;*.tiff;*.webp;*.wmf" End With If .Show = -1 Then file = .SelectedItems(1) End If End With 'change images on each sheets If Len(file) <> 0 Then For Each sht In ThisWorkbook.Sheets sht.Activate sht.Unprotect Set shp = sht.Shapes("logo") With shp t = .Top l = .Left w = .Width h = .Height .Delete End With sht.Pictures.Insert(file).Select With Selection .Name = "logo" .Top = t .Left = l .Width = w .Height = h End With sht.Protect Next End If Sheets(1).Activate End Sub
How do I put that in the code above? Thanks!
-
@garak0410 in your
With fd
section, you will have something to specify the directory. I think it isInititalFilename
With fd .AllowMultiSelect = False .InitialFilename = "\fileserver\drafting\logos\" With .Filters
-
@JaredBusch said in Quick VBA Help Needed:
.InitialFilename = "\fileserver\drafting\logos"
You saved my day...if I see you at SpiceWorld (if you go), I'll make sure to thank you in person...
-
@garak0410 said in Quick VBA Help Needed:
@JaredBusch said in Quick VBA Help Needed:
.InitialFilename = "\fileserver\drafting\logos"
You saved my day...if I see you at SpiceWorld (if you go), I'll make sure to thank you in person...
I'll be there.