Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
greaseman
 
Posts: n/a
Default Why can't I write out an Excel file?


I've got a VB project that cycles through a txt file and extracts data
from that txt file into Excel files. The project creates Excel files
based on what it finds in the txt file.

My problem: The code works beautifully on the first two sets of data it
finds, but when it encounters a third set of data, although the program
reads through the data, it does not create a resultant third Excel
file. I've stepped through the code and confirmed that data is being
encountered.

Is there a limit on the number of Excel workbooks that can be created?
Here is the code snippet I have at the end of my project, after data is
processed:

xls.activeworkbook.saveas Filename:=strFilename & ".xls",
ReadOnlyRecommended:=False, CreateBackup:=False

xls.activeworkbook.Close

xls.workbooks.Add
xls.Visible = True


Any help is most welcome! This is driving me crazy!!!!


--
greaseman
------------------------------------------------------------------------
greaseman's Profile: http://www.excelforum.com/member.php...o&userid=28808
View this thread: http://www.excelforum.com/showthread...hreadid=535496

  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Why can't I write out an Excel file?

Maybe making the excel session visible before the save would help debug the
problem.

Could it be that strFileName is not correct or that you're waiting with a "do
you want to overwrite this file" prompt hidden?

xls.displayalerts = false
'your save line
xls.displayalerts = true

would be one way to avoid this prompt.

greaseman wrote:

I've got a VB project that cycles through a txt file and extracts data
from that txt file into Excel files. The project creates Excel files
based on what it finds in the txt file.

My problem: The code works beautifully on the first two sets of data it
finds, but when it encounters a third set of data, although the program
reads through the data, it does not create a resultant third Excel
file. I've stepped through the code and confirmed that data is being
encountered.

Is there a limit on the number of Excel workbooks that can be created?
Here is the code snippet I have at the end of my project, after data is
processed:

xls.activeworkbook.saveas Filename:=strFilename & ".xls",
ReadOnlyRecommended:=False, CreateBackup:=False

xls.activeworkbook.Close

xls.workbooks.Add
xls.Visible = True

Any help is most welcome! This is driving me crazy!!!!

--
greaseman
------------------------------------------------------------------------
greaseman's Profile: http://www.excelforum.com/member.php...o&userid=28808
View this thread: http://www.excelforum.com/showthread...hreadid=535496


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
greaseman
 
Posts: n/a
Default Why can't I write out an Excel file?


Dave,

Thanks for your reply...... the program is not waiting on a "do
you want to overwrite this file" message, and also strFileName is
picked from a file selection form.....

I have no idea what is happening..... no error messages sho, and
tracing through code indicates that data is being "grabbed," it's just
not coming out to the Excel file.

If you have any more suggestions, please toss them at me......I'm going
crazy!


--
greaseman
------------------------------------------------------------------------
greaseman's Profile: http://www.excelforum.com/member.php...o&userid=28808
View this thread: http://www.excelforum.com/showthread...hreadid=535496

  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Why can't I write out an Excel file?

Just what I mentioned before--make that instance visible to see if you can see
anything strange happening.

Good luck.

greaseman wrote:

Dave,

Thanks for your reply...... the program is not waiting on a "do
you want to overwrite this file" message, and also strFileName is
picked from a file selection form.....

I have no idea what is happening..... no error messages sho, and
tracing through code indicates that data is being "grabbed," it's just
not coming out to the Excel file.

If you have any more suggestions, please toss them at me......I'm going
crazy!

--
greaseman
------------------------------------------------------------------------
greaseman's Profile: http://www.excelforum.com/member.php...o&userid=28808
View this thread: http://www.excelforum.com/showthread...hreadid=535496


--

Dave Peterson
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 write an excel formula to display the file save date? Bob-123456789 Excel Worksheet Functions 1 January 26th 06 07:50 PM
Reflecting info between an excel file and a word one or two excel file. Starriol Excel Discussion (Misc queries) 0 November 3rd 05 01:49 PM
TRYING TO SET UP EXCEL SPREADSHEET ON MY COMPUTER MEGTOM New Users to Excel 5 October 27th 05 03:06 AM
Access a excel file through FTP without write protection jj Excel Discussion (Misc queries) 0 October 9th 05 05:38 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 11:34 AM.

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"