Results 1 to 5 of 5
  1. #1
    Josha is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2019
    Location
    Victoria, Australia
    Posts
    42

    Arrow VBA code to prompt user with the 'Save As' dialog box instead of automatically saving in a directory

    So I have a database where students record their examination notes.



    At the end of their examination I expect them to add important photos to a Word document template called "Continuity Imaging Record" that I have pre-made. The Word document successfully pulls information from the Access database such as Examiner details, Examination date, Case number ect ect using bookmarks. That's not the issue.

    The issue is..... I want the code (below) to ask the student where do they want to save the file, instead of automatically saving there file in the same directory as the template file. Is there a piece of code that I can add below which will prompt the Save as dialog box for the student so they can navigate to their case folder and save it there?

    Any help will be appreciated it. Thank you

    Code:
    Private Sub cmdPrint_Click()
    
    Dim appWord As Word.Application
    Dim DOC As Word.Document
    'Avoid error 429, when Word isn’t open.
    On Error Resume Next
    Err.Clear
    'Set appWord object variable to running instance of Word.
    Set appWord = GetObject(, "Word.Application")
    If Err.Number <> 0 Then
    'If Word isn’t open, create a new instance of Word.
    Set appWord = New Word.Application
    End If
    Set DOC = appWord.Documents.Open("H:\Abilas 1.16.8\Continuity Imaging Record.docx", , True)
    With DOC
    .FormFields("flddateexam").Result = Me![Dateofexamination]
    .FormFields("fldexaminer").Result = Me![examiner]
    .FormFields("fldcasenum").Result = Me![Casenumber]
    .Visible = True
    .Activate
    .SaveAs2 Me![Filenamecont] &".docx"
    
    End
    Set DOC = Nothing
    Set appWord = Nothing
    Exit Sub
    
    errHandler:
    MsgBox Err.Number & ": " & Err.Description
    
    
    
    
    End With
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Use FileSystemObject file picker dialog. Simple Example:
    Code:
    Dim sFolder As String
    Dim fd As FileDialog
    Dim booResult As Boolean
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)
    fd.AllowMultiSelect = False
    fd.title = "Select folder"
    While booResult = False
        If fd.Show = True Then
            'folder path was selected
            booResult = True
            sFolder = fd.SelectedItems(1)
        End If
    Wend
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Josha is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2019
    Location
    Victoria, Australia
    Posts
    42
    When I compile the database it comes up with a compile error: User-define type not defined and then the following code is highlighted....

    Code:
    fd As FileDialog

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Do you have Microsoft Office x.x Object Library selected?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Josha is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2019
    Location
    Victoria, Australia
    Posts
    42
    That did it! Thanks!

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

Similar Threads

  1. Replies: 2
    Last Post: 08-28-2018, 10:38 AM
  2. Prompt Print Dialog
    By Eranka in forum Access
    Replies: 2
    Last Post: 06-01-2018, 08:30 AM
  3. save as prompt with hard code path
    By xopherira in forum Programming
    Replies: 8
    Last Post: 09-09-2015, 12:57 PM
  4. Replies: 7
    Last Post: 09-11-2014, 12:26 PM
  5. Replies: 5
    Last Post: 02-03-2014, 03:06 AM

Tags for this Thread

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