View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
cardfan3206 cardfan3206 is offline
external usenet poster
 
Posts: 12
Default Error 1004 SaveAs Object workbook failed

Thanks for te help Dave. I am now back to getting the runtime error 1004
that I was originally getting so I am not sure what else I can do to get this
to work.

"Dave Peterson" wrote:

I'm guessing you had a typo--you dropped the : from the filename:=mypath & ...

If that doesn't help, you should post your current code.

cardfan3206 wrote:

Thanks Ron. The code now executes but it is naming the file "False" instead
of the defined parameters in the code. Any ideas on this last issue?

"Ron de Bruin" wrote:

Untested in your code but try this

ActiveWorkbook.SaveAs Filename:=myPath & Filename & mySerial & FileFormat , 52


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"cardfan3206" wrote in message ...
Thanks Ron. To be quite honest, I just started learning about using vba to
execute routine things a couple weeks ago and although I tried to use the
site you gave me to solve my issue, I still don't seem to be able to figure
it out. Is there any other way to tell what is wrong with the save as
statement?

"Ron de Bruin" wrote:

See this page about your problem
http://www.rondebruin.nl/saveas.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"cardfan3206" wrote in message ...
I have the following code and am getting a saveas workbook failed error when
I reach the Activeworkbook.Saveas line of the code. I haven't changed the
code since last week and it worked then so I am not sure why I am getting
this error now. If anyone has any ideas what could be wrong I would
appreciate it.

Thanks!

Sub WorkbookClose()
'
' WorkbookClose Macro
' Formats file for printing and saves to directory
'
'

' Hides Rows that are empty
'
Dim rangeToTest As Range
Dim anyCell As Object

Set rangeToTest = Range("K13:K23")
For Each anyCell In rangeToTest
If IsEmpty(anyCell) Then
anyCell.EntireRow.Hidden = True
End If
Next

'Hides columns containing raw/unadjusted data

Columns("A:B").Select
Selection.EntireColumn.Hidden = True
Columns("J:V").Select
Selection.EntireColumn.Hidden = True
ChDir "G:\Compensation\Market Analysis Files\"


mySerial = ""
myPath = "G:\Compensation\Market Analysis Files\"
myFile = Sheets("Market Detail").Range("D9") & " - " & Sheets("Market
Detail").Range("D8") & " - " & Format(Date, "MM-DD-YYYY")
FileFormat = ".xlsm"

' create output using sequence 1 to n if file already exists
If Len(Dir(myPath & myFile & mySerial & myExt)) 0 Then

Do While Len(Dir(myPath & myFile & mySerial & myExt)) 0
mySerial = "(" & Val(Mid(mySerial, 2)) + 1 & ")"
Loop

End If

ActiveWorkbook.SaveAs Filename:=myPath & Filename & mySerial & FileFormat

Range("H12").Select
ThisWorkbook.Close
End Sub





--

Dave Peterson