ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Quick VBA Help Needed

    IT Discussion
    2
    4
    283
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • garak0410G
      garak0410
      last edited by

      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!

      JaredBuschJ 1 Reply Last reply Reply Quote 0
      • JaredBuschJ
        JaredBusch @garak0410
        last edited by

        @garak0410 in your With fd section, you will have something to specify the directory. I think it is InititalFilename

        With fd
            .AllowMultiSelect = False
            .InitialFilename = "\fileserver\drafting\logos\"
            With .Filters
        
        garak0410G 1 Reply Last reply Reply Quote 0
        • garak0410G
          garak0410 @JaredBusch
          last edited by

          @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...

          JaredBuschJ 1 Reply Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch @garak0410
            last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post