Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 259
Default Save ActiveWorkbook dilemma

Hi All

Could someone have a look at this code and give me a pointer as to where I
am going wrong and why the code halts on the .Save within the With Statement
please...

It should be saving to E: Drive 1st, then change directory to C: Drive and
do the same, ala, it is not....


Sub save_WB()

Dim E_FileSave As Workbook
Dim E_FilePath As String
Dim E_FileName As String

Dim C_FileSave As Workbook
Dim C_FilePath As String
Dim C_FileName As String

Dim FileExtStr As String
Dim FileFormatNum As Long

Set E_FileSave = ActiveWorkbook

E_FilePath = "E:\Work_Stuff\"
E_FileName = E_FileSave.Name
FileExtStr = ".xls"

With E_FileSave
.SaveAs E_FilePath & E_FileName & FileExtStr,
FileFormat:=FileFormatNum
End With

Set C_FileSave = ActiveWorkbook

T_FilePath = "C:\Other Work_Stuff\"
T_FileName = C_FileSave.Name
FileExtStr = ".xls"

With C_FileSave
.SaveAs C_FilePath & C_FileName & FileExtStr,
FileFormat:=FileFormatNum
End With

End Sub

TIA
Mick.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Save ActiveWorkbook dilemma

I don't see where you are setting a value for the FileFormatNum variable
that you are passing in to the FileFormat argument. That means FileFormatNum
is 0 when you call the .SaveAs method... none of the possible built-in VB
constants for this argument equate to a value of 0, so I'm guessing that is
your problem.

Rick Rothstein (MVP - Excel)



"Vacuum Sealed" wrote in message
nd.com...

Hi All

Could someone have a look at this code and give me a pointer as to where I
am going wrong and why the code halts on the .Save within the With
Statement
please...

It should be saving to E: Drive 1st, then change directory to C: Drive and
do the same, ala, it is not....


Sub save_WB()

Dim E_FileSave As Workbook
Dim E_FilePath As String
Dim E_FileName As String

Dim C_FileSave As Workbook
Dim C_FilePath As String
Dim C_FileName As String

Dim FileExtStr As String
Dim FileFormatNum As Long

Set E_FileSave = ActiveWorkbook

E_FilePath = "E:\Work_Stuff\"
E_FileName = E_FileSave.Name
FileExtStr = ".xls"

With E_FileSave
.SaveAs E_FilePath & E_FileName & FileExtStr,
FileFormat:=FileFormatNum
End With

Set C_FileSave = ActiveWorkbook

T_FilePath = "C:\Other Work_Stuff\"
T_FileName = C_FileSave.Name
FileExtStr = ".xls"

With C_FileSave
.SaveAs C_FilePath & C_FileName & FileExtStr,
FileFormat:=FileFormatNum
End With

End Sub

TIA
Mick.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 259
Default Save ActiveWorkbook dilemma

Thx for pointing that out Rick

I changed the code to this, but it only runs thru the 1st With and halts on
the 2nd, again the .SaveAs:

Sub save_WB()

Dim E_FileSave As Workbook
Dim E_FilePath As String
Dim E_FileName As String

Dim C_FileSave As Workbook
Dim C_FilePath As String
Dim C_FileName As String

Set E_FileSave = ActiveWorkbook

E_FilePath = "E:\Work_Stuff\"
E_FileName = E_FileSave.Name

With E_FileSave
.SaveAs E_FilePath & E_FileName
End With

Set C_FileSave = ActiveWorkbook

T_FilePath = "C:\Other Work_Stuff\"
T_FileName = C_FileSave.Name

With C_FileSave
.SaveAs C_FilePath & C_FileName
End With

End Sub

Cheers


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 259
Default Save ActiveWorkbook dilemma

Sorry Rick

Don't bother as I am a dill....

My Bad, as I actually have to have a directory named just that in the 2nd
With....Doh.....lol...

Mick.


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
Can i save activeworkbook to binary data before save ? badtoto Excel Programming 0 April 14th 08 02:32 AM
Save activeworkbook with a password [email protected] Excel Programming 2 June 4th 07 01:34 PM
Activeworkbook.save serge Excel Programming 0 February 9th 06 04:26 PM
ActiveWorkbook.Save DOESNT WORK !! slintz Excel Programming 8 July 22nd 05 10:42 PM
troubles with ActiveWorkbook.Save Gabriele C[_4_] Excel Programming 1 August 11th 04 05:35 PM


All times are GMT +1. The time now is 10:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"