+ Reply to Thread
Results 1 to 4 of 4

Save PDF to different location based on choice user

  1. #1
    Registered User
    Join Date
    10-31-2017
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    3

    Save PDF to different location based on choice user

    I'm trying to build a macro that saves a word document to a pdf file, based on the choice of a user.

    I have two questions:

    1) is there a way to replace the inputbox by a dropdown menu where the user selects option 1 or 2?
    2) the MsgBox doesn't give the location where the file is saved. What am I doing wrong?

    Thank you for your help.

    This is what I have:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Save PDF to different location based on choice user

    1. Not unless you employ a userform.
    2. OutputFileName is a property of ExportAsFixedFormat, not a variable. Thus it's not available outside that method. Try:
    Please Login or Register  to view this content.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    10-31-2017
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    3

    Re: Save PDF to different location based on choice user

    That works like a charm, thank you!

    I changed it a bit to have a default value and a messagebox when not value 1 or 2 is chosen. Now, the While Wend is missing, I would like to return to the inputbox when the wrong value is typed.

    [CODE][/Sub SaveAsPDF()
    Dim StrName As String, sPrompt As String, Rsp As Variant

    StrName = Split(ActiveDocument.Name, ".doc")(0) & ".pdf" 'huidige naam

    sPrompt = "Waar moet het bestand opgeslagen worden?" _
    & vbCr & "1. S:\ALGEMEEN\BRIEF" _
    & vbCr & "2. S:\ALGEMEEN\MAILING"
    Rsp = InputBox(sPrompt, "Keuzemenu", 1)

    Select Case Rsp
    Case 1: StrName = "T:\Joyce\1\" & StrName
    Case 2: StrName = "T:\Joyce\2\" & StrName
    Case Else: MsgBox "Kies 1 of 2"
    Exit Sub
    End Select

    ActiveDocument.ExportAsFixedFormat OutputFileName:=StrName, _
    ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, _
    OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
    From:=1, To:=1, Item:=wdExportDocumentContent, IncludeDocProps:=True, _
    KeepIRM:=True, CreateBookmarks:=wdExportCreateNoBookmarks, _
    DocStructureTags:=True, BitmapMissingFonts:=True, UseISO19005_1:=False
    MsgBox "PDF opgeslagen in: " & StrName
    End Sub

    CODE]

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Save PDF to different location based on choice user

    You could reimplement the loop with:
    Please Login or Register  to view this content.
    In which case you also don't need:
    Case Else: MsgBox "Kies 1 of 2"
    The whole point of not having the loop, though, is so the user can exit the sub if they change their mind.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Need To open and Save a folder location selected by user
    By bfenger in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2016, 05:10 AM
  2. Replies: 0
    Last Post: 07-28-2016, 08:43 AM
  3. [SOLVED] User input for save location?
    By fourmurphys in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-15-2013, 03:25 PM
  4. Need Save As script where user gets Drive/Folder choice but data establishes file name>
    By ILoveStMartin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-09-2013, 04:40 PM
  5. [SOLVED] Save workbook to folder of user choice
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2013, 09:14 PM
  6. Macro to prompt user for file name and save in location
    By Fungijus in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-21-2011, 02:16 PM
  7. [SOLVED] Allowing the user to specify save location
    By TimN in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2006, 12:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1