Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Calling Save

Hello once again,

I am calling save via code as such

if not activeworkbook.saved then activeworkbook.save

in Workbook_BeforeSave, I make a string to be my filename as such

sFileName="C:\Saveme.xls"

Then I call the saveas routine as such

ActiveWorkbook.SaveAs Filename:=sFileName, addtomru:=True,
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False

And low and behold, nothing happens.

However, when I click the save button from the toolbar, everything works
fine. What is the difference? How can I perform the same save routine as
the button click?

Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Calling Save

Ok, so I didn't know how to call the save directly from the toolbar so I
made this:

'Usage
dim x as CommadBarButton
set x = FindCommandButton("&Save")
if not x is nothing then x.execute

Function FindCommandButton(Caption As String) As CommandBarButton

Dim cmdbar As CommandBar
Dim cmdbtn As CommandBarButton
Dim cmdctl As CommandBarControl

For Each cmdbar In Application.CommandBars
For Each cmdctl In Application.CommandBars(cmdbar.Name).Controls
If cmdctl.Type = msoControlButton Then
Set cmdbtn = cmdctl

If cmdbtn.Caption = "&Save" Then
Set FindSave = cmdbtn
Exit Function
End If

End If
Next cmdctl
Next cmdbar

End Function

It seems to work pretty well


"AMDRIT" wrote in message
...
Hello once again,

I am calling save via code as such

if not activeworkbook.saved then activeworkbook.save

in Workbook_BeforeSave, I make a string to be my filename as such

sFileName="C:\Saveme.xls"

Then I call the saveas routine as such

ActiveWorkbook.SaveAs Filename:=sFileName, addtomru:=True,
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False

And low and behold, nothing happens.

However, when I click the save button from the toolbar, everything works
fine. What is the difference? How can I perform the same save routine as
the button click?

Thanks.



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
Calling a Sub from another shashi1515[_4_] Excel Programming 5 February 4th 06 03:57 AM
Need Help using/calling a DLL Trip[_3_] Excel Programming 1 January 9th 06 01:36 PM
Need Help Using/Calling DLL Please Trip[_3_] Excel Programming 0 January 8th 06 09:57 AM
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: harpscardiff[_10_] Excel Programming 8 November 10th 05 12:24 PM
Calling an Add-In BillCPA Excel Discussion (Misc queries) 2 August 11th 05 09:32 PM


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

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

About Us

"It's about Microsoft Excel"