PC Review


Reply
Thread Tools Rate Thread

Code Fails on SAVE

 
 
Thanks
Guest
Posts: n/a
 
      5th Jun 2009
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 With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      5th Jun 2009
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 With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      5th Jun 2009
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 With Quote
 
Thanks
Guest
Posts: n/a
 
      5th Jun 2009
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 With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      6th Jun 2009
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 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
save movie always fails without valid error code web stoker Windows XP MovieMaker 1 18th Feb 2009 04:44 PM
Excel fails on Save/Save As DanG Microsoft Excel Misc 11 16th May 2008 02:36 PM
Visual studio save fails and then wipes out the objejcts and code of my form Mark Microsoft Dot NET 0 21st Dec 2006 09:28 PM
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: harpscardiff Microsoft Excel Programming 8 10th Nov 2005 12:24 PM
Save As - Multiple Sheets fails to save as text file Ravee Srinivasan Microsoft Excel Programming 2 10th Nov 2003 04:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:01 PM.