Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Save Workbook As macro problem

Hi, I have the following code to save the current workbook with a specific
filename.
It is linked to a button launched from a custom menu.

Sub Save_File()
' Macro to Save file as ZFPW_dd-mm-yyyy.xls
Dim path As String, filename As String, filetype As String, file As String
path = "C:\Documents and Settings\username\My Documents\SOX
Reporting\Metrics"
file_name = "ZFPW_" & Format(Date, "dd-mm-yyyy")
filetype = ".xls"
file = path & file_name & filetype
ChDir path
ActiveWorkbook.SaveAs filename:=file
End Sub

When I run the macro, I get "Compile error: Wrong number of arguments or
invalid property assignment" with Format highlighted as the error.

I'm sure it's a minor fix, but it's not giving me any love at the moment.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Save Workbook As macro problem

I'm not seeing a problem here. What do you get when you do this

Debug.print Date
Debug.print Format(Date, "dd-mm-yyyy")

"D Zandveld" wrote:

Hi, I have the following code to save the current workbook with a specific
filename.
It is linked to a button launched from a custom menu.

Sub Save_File()
' Macro to Save file as ZFPW_dd-mm-yyyy.xls
Dim path As String, filename As String, filetype As String, file As String
path = "C:\Documents and Settings\username\My Documents\SOX
Reporting\Metrics"
file_name = "ZFPW_" & Format(Date, "dd-mm-yyyy")
filetype = ".xls"
file = path & file_name & filetype
ChDir path
ActiveWorkbook.SaveAs filename:=file
End Sub

When I run the macro, I get "Compile error: Wrong number of arguments or
invalid property assignment" with Format highlighted as the error.

I'm sure it's a minor fix, but it's not giving me any love at the moment.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Save Workbook As macro problem

Same error, but this time on Format in the debug code.

Do I need to declare 'Format' as anything? I didn't think so?

"Barb Reinhardt" wrote:

I'm not seeing a problem here. What do you get when you do this

Debug.print Date
Debug.print Format(Date, "dd-mm-yyyy")

"D Zandveld" wrote:

Hi, I have the following code to save the current workbook with a specific
filename.
It is linked to a button launched from a custom menu.

Sub Save_File()
' Macro to Save file as ZFPW_dd-mm-yyyy.xls
Dim path As String, filename As String, filetype As String, file As String
path = "C:\Documents and Settings\username\My Documents\SOX
Reporting\Metrics"
file_name = "ZFPW_" & Format(Date, "dd-mm-yyyy")
filetype = ".xls"
file = path & file_name & filetype
ChDir path
ActiveWorkbook.SaveAs filename:=file
End Sub

When I run the macro, I get "Compile error: Wrong number of arguments or
invalid property assignment" with Format highlighted as the error.

I'm sure it's a minor fix, but it's not giving me any love at the moment.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Save Workbook As macro problem

What application are you running this out of? I'm using Excel 2007. Might
you be running it from something besides Excel?

"D Zandveld" wrote:

Same error, but this time on Format in the debug code.

Do I need to declare 'Format' as anything? I didn't think so?

"Barb Reinhardt" wrote:

I'm not seeing a problem here. What do you get when you do this

Debug.print Date
Debug.print Format(Date, "dd-mm-yyyy")

"D Zandveld" wrote:

Hi, I have the following code to save the current workbook with a specific
filename.
It is linked to a button launched from a custom menu.

Sub Save_File()
' Macro to Save file as ZFPW_dd-mm-yyyy.xls
Dim path As String, filename As String, filetype As String, file As String
path = "C:\Documents and Settings\username\My Documents\SOX
Reporting\Metrics"
file_name = "ZFPW_" & Format(Date, "dd-mm-yyyy")
filetype = ".xls"
file = path & file_name & filetype
ChDir path
ActiveWorkbook.SaveAs filename:=file
End Sub

When I run the macro, I get "Compile error: Wrong number of arguments or
invalid property assignment" with Format highlighted as the error.

I'm sure it's a minor fix, but it's not giving me any love at the moment.

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Save Workbook As macro problem

Excel 2003

"Barb Reinhardt" wrote:

What application are you running this out of? I'm using Excel 2007. Might
you be running it from something besides Excel?

"D Zandveld" wrote:

Same error, but this time on Format in the debug code.

Do I need to declare 'Format' as anything? I didn't think so?

"Barb Reinhardt" wrote:

I'm not seeing a problem here. What do you get when you do this

Debug.print Date
Debug.print Format(Date, "dd-mm-yyyy")

"D Zandveld" wrote:

Hi, I have the following code to save the current workbook with a specific
filename.
It is linked to a button launched from a custom menu.

Sub Save_File()
' Macro to Save file as ZFPW_dd-mm-yyyy.xls
Dim path As String, filename As String, filetype As String, file As String
path = "C:\Documents and Settings\username\My Documents\SOX
Reporting\Metrics"
file_name = "ZFPW_" & Format(Date, "dd-mm-yyyy")
filetype = ".xls"
file = path & file_name & filetype
ChDir path
ActiveWorkbook.SaveAs filename:=file
End Sub

When I run the macro, I get "Compile error: Wrong number of arguments or
invalid property assignment" with Format highlighted as the error.

I'm sure it's a minor fix, but it's not giving me any love at the moment.

Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Save Workbook As macro problem

It'll take me a while to access Excel 2003, but you might try replacing
Format with WorksheetFunction.Text( )



"D Zandveld" wrote:

Excel 2003

"Barb Reinhardt" wrote:

What application are you running this out of? I'm using Excel 2007. Might
you be running it from something besides Excel?

"D Zandveld" wrote:

Same error, but this time on Format in the debug code.

Do I need to declare 'Format' as anything? I didn't think so?

"Barb Reinhardt" wrote:

I'm not seeing a problem here. What do you get when you do this

Debug.print Date
Debug.print Format(Date, "dd-mm-yyyy")

"D Zandveld" wrote:

Hi, I have the following code to save the current workbook with a specific
filename.
It is linked to a button launched from a custom menu.

Sub Save_File()
' Macro to Save file as ZFPW_dd-mm-yyyy.xls
Dim path As String, filename As String, filetype As String, file As String
path = "C:\Documents and Settings\username\My Documents\SOX
Reporting\Metrics"
file_name = "ZFPW_" & Format(Date, "dd-mm-yyyy")
filetype = ".xls"
file = path & file_name & filetype
ChDir path
ActiveWorkbook.SaveAs filename:=file
End Sub

When I run the macro, I get "Compile error: Wrong number of arguments or
invalid property assignment" with Format highlighted as the error.

I'm sure it's a minor fix, but it's not giving me any love at the moment.

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
Save workbook problem Sandy Excel Programming 3 March 21st 08 10:00 AM
Duplicating Changes from Column A and B of Master Workbook to ColumnA and B of Other Workbooks - - Please help me, I can save days if my problem jhong Excel Programming 1 March 10th 08 08:45 PM
"Save" macro problem, still prompted to save when closing workbook (?) StargateFanFromWork[_4_] Excel Programming 8 September 13th 06 04:49 PM
Problem when attempting to save Workbook with VBA project protected Friedrich Hofmann Excel Programming 4 November 15th 05 10:18 PM
Save Workbook Problem Jim Kobzeff Excel Programming 0 April 13th 05 03:21 AM


All times are GMT +1. The time now is 03:37 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"