BeforeClose and Workbooks.SaveAs Filename:=
I just read the back and forth between you and Joel. There is nothing wrong
with the syntax that you are using. If the workbook is not protected, it
should save to the new name without a problem. The line of code that you
mentioned later in the BeforeSave sub should not matter since it would not
have executed at that point. You mentioned that the workbood is read only.
Does that mean Protected? If so, remove the protection and see if it will
execute the SaveAs then.
"MeistersingerVonNurnberg" wrote:
Hi -
I performed everything as you stated. The values are correct.
Maybe it has something to do w the wb being set as readonly from a Windows /
DOS perspective...
Or, perhaps ... In the BeforeClose, all the way at the end,
ThisWorkbook.Saved = True has something to do w it
"JLGWhiz" wrote:
Seems very odd. Try putting a break point on the line after your SaveAs
line. Then
use the tool tip display to check the values of the two variables for
workbook name after it has executed and before the macro ends. If both are
correct at that point, and it still does not save or change the window
caption at the top of the screen, then there is a real problem.
"MeistersingerVonNurnberg" wrote:
Hi All -
I've got a function call to save a workbook in the ThisWorkbook BeforeClose.
The function contains the following line:
Workbooks(sWbName).SaveAs Filename:=var_FileName
where, sWbName is a String, which is passed to the function as
ThisWorkbook.Name
and, var_FileName is a local Variant that is set as follows:
var_FileName = Application.GetSaveAsFilename(not showing args)
For whatever reason, the SaveAs line is not working. It raises no Err. Through
the debugger, sWbName is set as the currently opened workbook, and is correct.
Also through the debugger, var_FileName gets set properly by
Application.GetSaveAsFilename(), and contains the full path to the file.
Any ideas? Thanks.
|