Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Code Stops Prematurely

I'm running code that saves a workbook abd then it should build a string and
then save another workbook. The code stops after the first workbook is saved
and the code never completes. Any suggestions on how to correct when using
the following:

ActiveWorkbook.SaveAs Filename:=XLSFILE, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

'return to the XLS file and close it
Windows(temp_xls_file).Activate
Workbooks(temp_xls_file).Close SaveChanges:=False

temp_file = "Hg Injection - " & the_sample_no & ".CSV"
CSVFILE = "V:\" + temp_file

'save a copy of the CSV file so that the XLS file will be imported
Windows("Hg Injection Exporter.xls").Activate
ActiveWorkbook.SaveAs Filename:=CSVFILE, FileFormat:= _
xlCSVMSDOS, CreateBackup:=False



--
Ray
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Code Stops Prematurely

Hi Ray,

Where does this code reside?



---
Regards,
Norman



"Halray" wrote in message
...
I'm running code that saves a workbook abd then it should build a string
and
then save another workbook. The code stops after the first workbook is
saved
and the code never completes. Any suggestions on how to correct when
using
the following:

ActiveWorkbook.SaveAs Filename:=XLSFILE, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

'return to the XLS file and close it
Windows(temp_xls_file).Activate
Workbooks(temp_xls_file).Close SaveChanges:=False

temp_file = "Hg Injection - " & the_sample_no & ".CSV"
CSVFILE = "V:\" + temp_file

'save a copy of the CSV file so that the XLS file will be imported
Windows("Hg Injection Exporter.xls").Activate
ActiveWorkbook.SaveAs Filename:=CSVFILE, FileFormat:= _
xlCSVMSDOS, CreateBackup:=False



--
Ray



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Code Stops Prematurely

Halray,

If your code is in temp_xls_file then your problem is:

When you SaveAs you change the name of the active workbook so it now becomes
XLSFILE_

Windows(temp_xls_file).Activate will fail as there is no longer a file of
this name open.

Henry

"Halray" wrote in message
...
I'm running code that saves a workbook abd then it should build a string
and
then save another workbook. The code stops after the first workbook is
saved
and the code never completes. Any suggestions on how to correct when
using
the following:

ActiveWorkbook.SaveAs Filename:=XLSFILE, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

'return to the XLS file and close it
Windows(temp_xls_file).Activate
Workbooks(temp_xls_file).Close SaveChanges:=False

temp_file = "Hg Injection - " & the_sample_no & ".CSV"
CSVFILE = "V:\" + temp_file

'save a copy of the CSV file so that the XLS file will be imported
Windows("Hg Injection Exporter.xls").Activate
ActiveWorkbook.SaveAs Filename:=CSVFILE, FileFormat:= _
xlCSVMSDOS, CreateBackup:=False



--
Ray



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Code Stops Prematurely

Thanks for the sugesstions - I found a work around (not sure if it's the best?)

I disabled alerts with:
Application.DisplayAlerts = False
then I saved all files as needed and quit Excel with:
Application.Quit

Thanks again for your time and efforts.

--
Ray


"Henry" wrote:

Halray,

If your code is in temp_xls_file then your problem is:

When you SaveAs you change the name of the active workbook so it now becomes
XLSFILE_

Windows(temp_xls_file).Activate will fail as there is no longer a file of
this name open.

Henry

"Halray" wrote in message
...
I'm running code that saves a workbook abd then it should build a string
and
then save another workbook. The code stops after the first workbook is
saved
and the code never completes. Any suggestions on how to correct when
using
the following:

ActiveWorkbook.SaveAs Filename:=XLSFILE, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

'return to the XLS file and close it
Windows(temp_xls_file).Activate
Workbooks(temp_xls_file).Close SaveChanges:=False

temp_file = "Hg Injection - " & the_sample_no & ".CSV"
CSVFILE = "V:\" + temp_file

'save a copy of the CSV file so that the XLS file will be imported
Windows("Hg Injection Exporter.xls").Activate
ActiveWorkbook.SaveAs Filename:=CSVFILE, FileFormat:= _
xlCSVMSDOS, CreateBackup:=False



--
Ray




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
Instead of debugging, code just stops running [email protected] Excel Discussion (Misc queries) 1 August 13th 08 07:26 PM
VB Code stops working Michelle K Excel Programming 17 August 17th 07 05:58 PM
Code stops at range Pat Excel Programming 3 February 16th 05 07:02 PM
(trying again...) code stops executing Mark Kubicki Excel Programming 0 December 4th 03 02:00 PM
VBA code stops executing Mark Kubicki Excel Programming 0 December 3rd 03 06:47 PM


All times are GMT +1. The time now is 12:51 PM.

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"