Code Fails on SAVE

T

Thanks

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!
 
J

Jacob Skaria

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
 
J

Jacob Skaria

This will do..

ActiveWorkbook.SaveAs strFile, Fileformat:=52

If this post helps click Yes
 
T

Thanks

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
 
J

Jacob Skaria

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top