vba - Save an Excel file as PDF to a specific path -


i save excel file .pdf file specific location , send file in mail.

i'm using office 2000 :|

this code far:

application.activeprinter = "pdf995 on ne00:" activesheet.pagesetup.printarea = range("a68").value activewindow.selectedsheets.printout copies:=1, activeprinter:= _     "pdf995 on ne00:", collate:=true         set wb = activeworkbook         set oapp = createobject("outlook.application")         set omail = oapp.createitem(0)         omail             .to = range("b61").value             .subject = "approved"             .body             .display             rows("81:134").select             selection.entirerow.hidden = true         end 

i can save file , mail it, can't save specific location.

i need able specificy path "c:\path\file.pdf".

if have file saved fixed location you're unable choose where, last resort use fso's movefile move specified location

eg. if file saved "c:\temp\file1.pdf", , want on desktop

'initialise first' set fso = createobject("scripting.filesystemobject") ... 'after procedure' desired_destination = "c:\windows\desktop\" target_file = "c:\temp\file1.pdf"  fso.movefile target_file, desired_destination 

if want check existing file conflict (i believe fso's move doesn't allow overwrite), use copyfile over-write switched on delete source file if necessary

if you'd use file dialog choose destination, can use useraccounts.commondialog object (although doesn't work vista) or safrcfiledlg.fileopen (pretty works on xp) or borrow ie prompted box. (unfortunately options aren't great vbs knowledge)

check them out here: http://www.robvanderwoude.com/vbstech_ui_fileopen.php


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -