Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2017, 11:59 PM
cutemich cutemich is offline Save to PDF with predetermined filename and specific folder path Windows 10 Save to PDF with predetermined filename and specific folder path Office 2013
Novice
Save to PDF with predetermined filename and specific folder path
 
Join Date: May 2017
Location: Philippines
Posts: 1
cutemich is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 05-09-2017, 06:27 PM
macropod's Avatar
macropod macropod is offline Save to PDF with predetermined filename and specific folder path Windows 7 64bit Save to PDF with predetermined filename and specific folder path Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit Filename Path? Cyberseeker Excel Programming 7 03-28-2017 07:23 AM
Save to PDF with predetermined filename and specific folder path 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 to PDF with predetermined filename and specific folder path 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft