PC Review


Reply
Thread Tools Rate Thread

How to capture Excel Save As dialog box?

 
 
=?Utf-8?B?QXJ1bmEgQWtlbGxh?=
Guest
Posts: n/a
 
      9th May 2007
My application is addin to Excel. I am trying to capture Excel Save and
Cancel buttons on Save As dialog box - so that I can call methods relevant to
my app depending on what user pressed. Is there a way to capture those events?

Thanks in advance!

--
Aruna
 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      9th May 2007
On May 9, 4:15 pm, Aruna Akella
<ArunaAke...@discussions.microsoft.com> wrote:
> My application is addin to Excel. I am trying to capture Excel Save and
> Cancel buttons on Save As dialog box - so that I can call methods relevant to
> my app depending on what user pressed. Is there a way to capture those events?
>
> Thanks in advance!
>
> --
> Aruna


Something like this what you're after?

Sub foo()
Dim saveName As String
saveName = Application.GetSaveAsFilename(fileFilter:="Excel Files
(*.xls), *.xls")
If saveName = False Or saveName = "" Then
MsgBox "No name entered or selected or canel button pressed"
Else
MsgBox saveName
End If
End Sub

HTH
-Jeff-

 
Reply With Quote
 
=?Utf-8?B?QXJ1bmEgQWtlbGxh?=
Guest
Posts: n/a
 
      10th May 2007
this is showing Save (or Save As dialog box 2 times)... any idea on how to
disable them? I did try disabling events & also set cancel = true at the end
- so that it will show only one time, but this didn't help - it didn't save
the workbook...
--
Aruna


"JW" wrote:

> On May 9, 4:15 pm, Aruna Akella
> <ArunaAke...@discussions.microsoft.com> wrote:
> > My application is addin to Excel. I am trying to capture Excel Save and
> > Cancel buttons on Save As dialog box - so that I can call methods relevant to
> > my app depending on what user pressed. Is there a way to capture those events?
> >
> > Thanks in advance!
> >
> > --
> > Aruna

>
> Something like this what you're after?
>
> Sub foo()
> Dim saveName As String
> saveName = Application.GetSaveAsFilename(fileFilter:="Excel Files
> (*.xls), *.xls")
> If saveName = False Or saveName = "" Then
> MsgBox "No name entered or selected or canel button pressed"
> Else
> MsgBox saveName
> End If
> End Sub
>
> HTH
> -Jeff-
>
>

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      10th May 2007
The posted code will not display the dialog twice.

GetSaveAsFileName does not save the file, just asks the user for a file
name. The programmer has to handle saving the file.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Aruna Akella" <(E-Mail Removed)> wrote in message
news:7A41AF76-FB24-4B10-BC41-(E-Mail Removed)...
> this is showing Save (or Save As dialog box 2 times)... any idea on how to
> disable them? I did try disabling events & also set cancel = true at the
> end
> - so that it will show only one time, but this didn't help - it didn't
> save
> the workbook...
> --
> Aruna
>
>
> "JW" wrote:
>
>> On May 9, 4:15 pm, Aruna Akella
>> <ArunaAke...@discussions.microsoft.com> wrote:
>> > My application is addin to Excel. I am trying to capture Excel Save and
>> > Cancel buttons on Save As dialog box - so that I can call methods
>> > relevant to
>> > my app depending on what user pressed. Is there a way to capture those
>> > events?
>> >
>> > Thanks in advance!
>> >
>> > --
>> > Aruna

>>
>> Something like this what you're after?
>>
>> Sub foo()
>> Dim saveName As String
>> saveName = Application.GetSaveAsFilename(fileFilter:="Excel Files
>> (*.xls), *.xls")
>> If saveName = False Or saveName = "" Then
>> MsgBox "No name entered or selected or canel button pressed"
>> Else
>> MsgBox saveName
>> End If
>> End Sub
>>
>> HTH
>> -Jeff-
>>
>>



 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      12th May 2007
One way would be the capture the BeforeSave event, test the SaveAsUI
parameter and if true, set Cancel to True and put up your own dialog.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting LLC
www.cpearson.com
(email on the web site)

"Aruna Akella" <(E-Mail Removed)> wrote in message
news:9EDCC992-A042-47A8-BBA6-(E-Mail Removed)...
> My application is addin to Excel. I am trying to capture Excel Save and
> Cancel buttons on Save As dialog box - so that I can call methods relevant
> to
> my app depending on what user pressed. Is there a way to capture those
> events?
>
> Thanks in advance!
>
> --
> Aruna



 
Reply With Quote
 
=?Utf-8?B?QWRyaWFuIEpvaG5zb24sIENB?=
Guest
Posts: n/a
 
      14th May 2007
I've been working on a similar procedure, and have used the method suggested
by Chip below.

I created a class and include the declaration in that class:
'Public WithEvents xlapp As Application'

I then create an instance of that class when ThisWorkbook is opened - the
technique Chip outlines on his very useful website.

It all works fine, unless I click on the stop button in the VBA editor, or
something similar, which destroys the object set up to capture the
application events.

Is there anyway around this?

Thanks.

Adrian.

"Chip Pearson" wrote:

> One way would be the capture the BeforeSave event, test the SaveAsUI
> parameter and if true, set Cancel to True and put up your own dialog.
>
>
> --
> Cordially,
> Chip Pearson
> Microsoft MVP - Excel
> Pearson Software Consulting LLC
> www.cpearson.com
> (email on the web site)
>
> "Aruna Akella" <(E-Mail Removed)> wrote in message
> news:9EDCC992-A042-47A8-BBA6-(E-Mail Removed)...
> > My application is addin to Excel. I am trying to capture Excel Save and
> > Cancel buttons on Save As dialog box - so that I can call methods relevant
> > to
> > my app depending on what user pressed. Is there a way to capture those
> > events?
> >
> > Thanks in advance!
> >
> > --
> > Aruna

>
>
>

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      15th May 2007
I've never found a satisfactory way around this. I tend to insert calls to
the routine that creates the xlApp object in a lot of places, so the object
is assured of being around "most of the time". Then I also put a button that
explicitly recreates the object somewhere in the menu.

Generally this is less of a problem when my users are using the programs
than when I am, since they don't go messing about in the VB Editor, and they
don't go crashing lots of things. (My development environment is a mess.)

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Adrian Johnson, CA" <Adrian Johnson, (E-Mail Removed)> wrote in
message news:6BD48058-4404-49EC-A542-(E-Mail Removed)...
> I've been working on a similar procedure, and have used the method
> suggested
> by Chip below.
>
> I created a class and include the declaration in that class:
> 'Public WithEvents xlapp As Application'
>
> I then create an instance of that class when ThisWorkbook is opened - the
> technique Chip outlines on his very useful website.
>
> It all works fine, unless I click on the stop button in the VBA editor, or
> something similar, which destroys the object set up to capture the
> application events.
>
> Is there anyway around this?
>
> Thanks.
>
> Adrian.
>
> "Chip Pearson" wrote:
>
>> One way would be the capture the BeforeSave event, test the SaveAsUI
>> parameter and if true, set Cancel to True and put up your own dialog.
>>
>>
>> --
>> Cordially,
>> Chip Pearson
>> Microsoft MVP - Excel
>> Pearson Software Consulting LLC
>> www.cpearson.com
>> (email on the web site)
>>
>> "Aruna Akella" <(E-Mail Removed)> wrote in message
>> news:9EDCC992-A042-47A8-BBA6-(E-Mail Removed)...
>> > My application is addin to Excel. I am trying to capture Excel Save and
>> > Cancel buttons on Save As dialog box - so that I can call methods
>> > relevant
>> > to
>> > my app depending on what user pressed. Is there a way to capture those
>> > events?
>> >
>> > Thanks in advance!
>> >
>> > --
>> > Aruna

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?QWRyaWFuIEpvaG5zb24sIENB?=
Guest
Posts: n/a
 
      15th May 2007
A shame there doesn't appear to be a way round it. Thanks for the advice
though Jon.

"Jon Peltier" wrote:

> I've never found a satisfactory way around this. I tend to insert calls to
> the routine that creates the xlApp object in a lot of places, so the object
> is assured of being around "most of the time". Then I also put a button that
> explicitly recreates the object somewhere in the menu.
>
> Generally this is less of a problem when my users are using the programs
> than when I am, since they don't go messing about in the VB Editor, and they
> don't go crashing lots of things. (My development environment is a mess.)
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> http://PeltierTech.com
> _______
>
>
> "Adrian Johnson, CA" <Adrian Johnson, (E-Mail Removed)> wrote in
> message news:6BD48058-4404-49EC-A542-(E-Mail Removed)...
> > I've been working on a similar procedure, and have used the method
> > suggested
> > by Chip below.
> >
> > I created a class and include the declaration in that class:
> > 'Public WithEvents xlapp As Application'
> >
> > I then create an instance of that class when ThisWorkbook is opened - the
> > technique Chip outlines on his very useful website.
> >
> > It all works fine, unless I click on the stop button in the VBA editor, or
> > something similar, which destroys the object set up to capture the
> > application events.
> >
> > Is there anyway around this?
> >
> > Thanks.
> >
> > Adrian.
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 - Save as dialog box VBA Noob Microsoft Excel Programming 9 16th Aug 2011 07:17 PM
Save Excel Worksheet As CSV - No Save As Dialog =?Utf-8?B?U1FMU2VydmFudA==?= Microsoft Excel Programming 1 29th Sep 2006 12:36 PM
RE: Excel - capture save file name using dialogue box =?Utf-8?B?UGF1bA==?= Microsoft Excel Misc 3 13th Aug 2004 10:27 PM
Excel - capture save file name using dialogue box jeff Microsoft Excel Misc 0 12th Aug 2004 09:43 PM
Excel save as dialog box is very slow Abdul Microsoft Excel Setup 1 2nd Jul 2004 01:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:56 PM.