Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Code Fails on SAVE

Hello
The following code gives me Incorrect Function on the save line. What does
this mean and how do I fix it?

Dim strMonth As String
Dim strYear As String

Range("B36:X36").Select
Selection.Copy
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4:X35").Select
Application.CutCopyMode = False
Selection.ClearContents

strMonth = InputBox("Enter Reporting Month 01-12")
strYear = InputBox("Enter Reporting Year")

ActiveWorkbook.SaveAs Filename:="G:\" & strYear & "\" & strYear & "-" &
strMonth & "\Turbine log " & strYear & "-" & strMonth & ".xlsm",
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

Thanks!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Code Fails on SAVE

Try the below. You dont need to declare the month as a string. Instead
declare as a numeric and use format function to zero pad...

Dim strFile as String

strfile = "G:\" & strYear & "\" & strYear & "-" & Format(strMonth, "00") & _
"\Turbine log " & strYear & "-" & Format(strMonth, "00") & ".xlsm"

ActiveWorkbook.SaveAs Filename:=strFile, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

If this post helps click Yes
---------------
Jacob Skaria


"Thanks" wrote:

Hello
The following code gives me Incorrect Function on the save line. What does
this mean and how do I fix it?

Dim strMonth As String
Dim strYear As String

Range("B36:X36").Select
Selection.Copy
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4:X35").Select
Application.CutCopyMode = False
Selection.ClearContents

strMonth = InputBox("Enter Reporting Month 01-12")
strYear = InputBox("Enter Reporting Year")

ActiveWorkbook.SaveAs Filename:="G:\" & strYear & "\" & strYear & "-" &
strMonth & "\Turbine log " & strYear & "-" & strMonth & ".xlsm",
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Code Fails on SAVE

This will do..

ActiveWorkbook.SaveAs strFile, Fileformat:=52

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Try the below. You dont need to declare the month as a string. Instead
declare as a numeric and use format function to zero pad...

Dim strFile as String

strfile = "G:\" & strYear & "\" & strYear & "-" & Format(strMonth, "00") & _
"\Turbine log " & strYear & "-" & Format(strMonth, "00") & ".xlsm"

ActiveWorkbook.SaveAs Filename:=strFile, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

If this post helps click Yes
---------------
Jacob Skaria


"Thanks" wrote:

Hello
The following code gives me Incorrect Function on the save line. What does
this mean and how do I fix it?

Dim strMonth As String
Dim strYear As String

Range("B36:X36").Select
Selection.Copy
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4:X35").Select
Application.CutCopyMode = False
Selection.ClearContents

strMonth = InputBox("Enter Reporting Month 01-12")
strYear = InputBox("Enter Reporting Year")

ActiveWorkbook.SaveAs Filename:="G:\" & strYear & "\" & strYear & "-" &
strMonth & "\Turbine log " & strYear & "-" & strMonth & ".xlsm",
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Code Fails on SAVE

OK Almost have it. Your code worked through saving the file but I get
Application-defined or object-defined error after the save.

Thanks for your help


"Jacob Skaria" wrote:

This will do..

ActiveWorkbook.SaveAs strFile, Fileformat:=52

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Try the below. You dont need to declare the month as a string. Instead
declare as a numeric and use format function to zero pad...

Dim strFile as String

strfile = "G:\" & strYear & "\" & strYear & "-" & Format(strMonth, "00") & _
"\Turbine log " & strYear & "-" & Format(strMonth, "00") & ".xlsm"

ActiveWorkbook.SaveAs Filename:=strFile, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

If this post helps click Yes
---------------
Jacob Skaria


"Thanks" wrote:

Hello
The following code gives me Incorrect Function on the save line. What does
this mean and how do I fix it?

Dim strMonth As String
Dim strYear As String

Range("B36:X36").Select
Selection.Copy
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4:X35").Select
Application.CutCopyMode = False
Selection.ClearContents

strMonth = InputBox("Enter Reporting Month 01-12")
strYear = InputBox("Enter Reporting Year")

ActiveWorkbook.SaveAs Filename:="G:\" & strYear & "\" & strYear & "-" &
strMonth & "\Turbine log " & strYear & "-" & strMonth & ".xlsm",
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

Thanks!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Code Fails on SAVE

You can test the save code by assigning another file name to strFile (say
"c:\test.xlsm"). This shouldnt be a problem. Check your folder paths..

If this post helps click Yes
---------------
Jacob Skaria


"Thanks" wrote:

OK Almost have it. Your code worked through saving the file but I get
Application-defined or object-defined error after the save.

Thanks for your help


"Jacob Skaria" wrote:

This will do..

ActiveWorkbook.SaveAs strFile, Fileformat:=52

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Try the below. You dont need to declare the month as a string. Instead
declare as a numeric and use format function to zero pad...

Dim strFile as String

strfile = "G:\" & strYear & "\" & strYear & "-" & Format(strMonth, "00") & _
"\Turbine log " & strYear & "-" & Format(strMonth, "00") & ".xlsm"

ActiveWorkbook.SaveAs Filename:=strFile, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

If this post helps click Yes
---------------
Jacob Skaria


"Thanks" wrote:

Hello
The following code gives me Incorrect Function on the save line. What does
this mean and how do I fix it?

Dim strMonth As String
Dim strYear As String

Range("B36:X36").Select
Selection.Copy
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4:X35").Select
Application.CutCopyMode = False
Selection.ClearContents

strMonth = InputBox("Enter Reporting Month 01-12")
strYear = InputBox("Enter Reporting Year")

ActiveWorkbook.SaveAs Filename:="G:\" & strYear & "\" & strYear & "-" &
strMonth & "\Turbine log " & strYear & "-" & strMonth & ".xlsm",
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

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
Excel fails on Save/Save As DanG[_2_] Excel Discussion (Misc queries) 11 May 16th 08 02:36 PM
XLBook.Save fails in Excel 2007 D.P. Roberts Excel Programming 1 November 27th 06 07:38 PM
Excel fails to save ChrisH Excel Discussion (Misc queries) 3 January 6th 06 01:30 PM
Excel fails to save properly Rolls Excel Discussion (Misc queries) 1 April 22nd 05 07:00 PM
Save As - Multiple Sheets fails to save as text file Ravee Srinivasan Excel Programming 2 November 10th 03 04:05 PM


All times are GMT +1. The time now is 03:14 AM.

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"