title: VBA - Browsing, selecting file and saving file as
body: <p>I am creating an access database with forms and reports. in one of my forms I want to be able to go to a folder selecting a file (.pdf, .doc, .xls) and then saving it in a dedicated "attachments" folder.</p>
  
  <p>I know about OLE objects and the attachment functions, but both of these would be saving the attachments within the database perse. I am trying to stay away from this since it is imperative to have readily access to the attachments and also to make the database lighter.</p>
  
  <p>I have been playing in VBA with </p>
  
  <pre><code>Application.FileDialog(msoFileDialogFilePicker)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Application.FileDialog(msoFileDialogSaveAs)
  </code></pre>
  
  <p>this is what I have so far but it is not working:</p>
  
  <pre><code>Option Compare Database
  
  Private Sub Select_Save_Click()
  
  Call SelectFile
  
  End Sub
  
  
  Public Function SelectFile() As String
  
  
  
  
   Dim FD As FileDialog
   Dim File_Name As String
   Dim path As String
  
  path = "O:\foldername"
  
  Set FD = Application.FileDialog(msoFileDialogFilePicker)
  
  With FD
      .AllowMultiSelect = False
      .Title = "Please select file to save as attachment"
      If .Show = True Then
  
          File_Name = Dir(.SelectedItems(1))
  
          SelectFile = .SelectedItems(1)
  
          new_name = path &amp; File_Name
  
          .SelectedItems.Item(1).SaveAsFile new_name
  
          Me.Attach_Save = new_name
  
  
      Else
          Exit Function
      End If
  
      Set FD = Nothing
  
  End With
  
  
  
  End Function
  </code></pre>