Results 1 to 3 of 3
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Selecting Save to location

    I am trying to get the user to select the save to location, but also to have the file named. I can open the window, but don't know how to put the filename in.



    Code:
    Dim F As Object, varItem As Variant
    Dim strFolder As String, FileName As String
    
    FileName = "ThreadStatus " & Format(Date,"ddmmmyyyy") & ".pdf"
    
    Set F = Application.FileDialog(msoFileDialogSaveAs)
        If F.Show Then
               strFolder = Left(varItem, Len(varItem) - Len(FileName))
    
    DoCmd.OutputToacOutputReport, "ReportThreadHeaders", "PDFFormat(*.pdf)", strFolder & "ThreadStatus " & Tod & ".pdf", False,"", , acExportQualityPrint
    Else: End If End Sub

    I was also looking at .browseforfolders, but thought this may be easier.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    user picks the file to save to
    Code:
    sub btnSelectFile_click()
      vFile =  strFolder & "ThreadStatus " & Tod & ".pdf"
      vTarg = SaveAs1(vFile)
      If Not IsEmpty(vTarg) Then    DoCmd.OutputToacOutputReport, "ReportThreadHeaders", "PDFFormat(*.pdf)",vTarg , False,"", , acExportQualityPrint
      
    end sub
    put this code into a MODULE for user to pick the file
    Code:
    Public Function SaveAs1(ByVal pvDfltFile)
    '===================
    'YOU MUST ADD REFERENCE : Microsoft Office xx.0 Object Library, in vbe menu, TOOLS, REFERENCES
    '===================
    With Application.FileDialog(msoFileDialogSaveAs)
        .AllowMultiSelect = False
        .Title = "Locate a file to Save"
        .ButtonName = "Save"
        .InitialFileName = pvDfltFile
        .InitialView = msoFileDialogViewList    'msoFileDialogViewThumbnail
        
            If .Show = 0 Then
               'There is a problem
               Exit Function
            End If
        
        'Save the first file selected
        SaveAs1 = Trim(.SelectedItems(1))
    End With
    End Function

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Thanks ranman256,

    Worked like a charm, I did add a little to not get another 2 popups if you canceled the first.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 10-18-2018, 08:09 PM
  2. Replies: 3
    Last Post: 06-18-2016, 09:06 AM
  3. Replies: 4
    Last Post: 08-26-2015, 02:30 PM
  4. Replies: 3
    Last Post: 12-13-2012, 01:09 PM
  5. Replies: 4
    Last Post: 08-26-2012, 10:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums