#1
|
|||
|
|||
Save to PDF with predetermined filename and specific folder path
Hi,
I am new to this. What I want to achieve is when I run the macro it will save it to to PDF with a filename extracted from forms and predetermined values then save it to a specific path folder. Can somebody help me please. |
#2
|
||||
|
||||
You really haven't given enough information to go on, as to either the path or what these 'forms' are.
Here's some code to get you started. It assumes the desired filename is in the first content control in the document and that you want to save the file to the user's 'Documents' folder. The first sub pops up a populated SaveAs dialogue; the second simply saves the file without prompting. Code:
Sub SaveDocAsPDF1() Application.ScreenUpdating = False Dim StrFlNm As String With ActiveDocument StrFlNm = .ContentControls(1).Range.Text With Application.Dialogs(wdDialogFileSaveAs) .Name = "C:\" & Environ("UserName") & "\Documents\" & StrFlNm .Format = wdFormatPDF .Show End With End With Application.ScreenUpdating = True End Sub Sub SaveDocAsPDF2() Application.ScreenUpdating = False Dim StrFlNm As String With ActiveDocument StrFlNm = .ContentControls(1).Range.Text .SaveAs2 FileName = "C:\" & Environ("UserName") & "\Documents\" & StrFlNm & ".pdf", FileFormat:=wdFormatPDF End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Edit Filename Path? | Cyberseeker | Excel Programming | 7 | 03-28-2017 07:23 AM |
How can I save all attachments in a folder with specific criteria? | terrymac | Outlook | 1 | 11-12-2015 06:55 AM |
use full path for filename | ruggb | Word | 1 | 08-21-2015 05:10 AM |
Save As PDF Macro/VBA with Predetermined File Name | DefinedDesign | Word VBA | 9 | 10-29-2014 01:48 PM |
save a file with a predetermined date in VBA | lingering | Word VBA | 1 | 03-23-2014 07:47 PM |