Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Button to Save File as PDF

I am using Excel 2007, and it already has the ability to Save As PDF.
However, I would like to add a button to the sheet that allows me to
click it and then a dialog box pops up to let me browse to where I
want to save the file and what I want to name it, and only allowing it
to be Saved as a PDF.

I have found some information, but most of what I have found involves
using other data on the sheet to pre-deternine the name and/or
location of the file.

Any help would be appreciated.

thanks!

magmike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Button to Save File as PDF

hi magmike,

fileSaveName = Application.GetSaveAsFilename(fileFilter:="PDF Files (*.pdf), *.pdf")


--
isabelle
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Button to Save File as PDF

On Dec 1, 6:42*pm, isabelle wrote:
hi magmike,

fileSaveName = Application.GetSaveAsFilename(fileFilter:="PDF Files (*.pdf), *.pdf")

--
isabelle


Thank you for your help Isabell, however there are two problems with
this...

(1) The name field for the file is filled in with a suggestion based
on the file name of the workbook - is it possible for it to be blank?
(2) Once named, browsed to and then saved - the file doesn't actually
save anywhere. Where is it going? Or am I missing a command?

Thanks in advance for your help.

magmike
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Button to Save File as PDF

magmike wrote:

On Dec 1, 6:42*pm, isabelle wrote:
hi magmike,

fileSaveName = Application.GetSaveAsFilename(fileFilter:="PDF Files
(*.pdf), *.pdf")

--
isabelle


Thank you for your help Isabell, however there are two problems with
this...

(1) The name field for the file is filled in with a suggestion based
on the file name of the workbook - is it possible for it to be blank?


fileSaveName = Application.GetSaveAsFilename( _
InitialFilename:="", FileFilter:="PDF Files (*.pdf), *.pdf")

(2) Once named, browsed to and then saved - the file doesn't actually
save anywhere. Where is it going? Or am I missing a command?


Are you doing SaveAs and just not finding the file? Try searching for the
file name to see where it's going.

If you're not doing SaveAs, that's your problem right there. From the help
file:
GetSaveAsFilename Method
Displays the standard Save As dialog box and gets a file name from the
user without actually saving any files.

--
I hate your job more than mine. And mine gives me nightmares.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Button to Save File as PDF

hi magmike,

VBA Help "Built In Dialog Arguments" lists the second argument of xlSaveAs as type_num
on xl2002, type_num = 1 gives .xls and there is no possibility for pdf
but on xl2007 it will be different you have to find the type_num for pdf

Application.Dialogs(xlDialogSaveAs).Show , 2 'adap type_num

'if you want to propose a file name

Application.Dialogs(xlDialogSaveAs).Show "default fileName", 2


--
isabelle



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Button to Save File as PDF

i can not verify this, if you will do the test


Dim fd As FileDialog, ffs As FileDialogFilters
Set fd = Application.FileDialog(msoFileDialogSaveAs)
With fd
Set ffs = .Filters("PDF Files (*.pdf), *.pdf")
End With


anotherway with Common Dialog Control
http://access.mvps.org/access/api/ap...pi/api0001.htm



--
isabelle

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Button to Save File as PDF

isabelle presented the following explanation :
i can not verify this, if you will do the test


Dim fd As FileDialog, ffs As FileDialogFilters
Set fd = Application.FileDialog(msoFileDialogSaveAs)
With fd
Set ffs = .Filters("PDF Files (*.pdf), *.pdf")
End With


anotherway with Common Dialog Control
http://access.mvps.org/access/api/ap...pi/api0001.htm


Common Dialog Control is no longer supported/provided as of Win 6.x and
so would have to be shipped and registered to all machines using the
project if the ocx was not present. I'd stick with using
Application.FileDialog()!

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Button to copy, save a sheet in a new file FSt1[_2_] Excel Programming 0 May 10th 11 07:48 AM
Button to copy, save a sheet in a new file FSt1[_2_] Excel Programming 0 May 10th 11 07:27 AM
Cancel Button on file save lwm Excel Programming 3 January 19th 08 02:35 AM
Save as new file command button EnGo Excel Programming 2 July 28th 06 02:55 PM
Browse Button for File Save Todd Huttenstine[_2_] Excel Programming 4 December 22nd 03 03:28 AM


All times are GMT +1. The time now is 05:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"