Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Automation of Excel to perform simple tasks on many workbooks.

I want to manipulate many Excel workbooks without having to open and enter
commands in each of them. If I have a folder with 1000 Excel workbooks, I
would like to run a script that could open each, tell each to save its
worksheets as plain text, and then close each. I could then use Perl to
search or index the plain text files.
The sequence of commands seems to be predictable, and therefore
scriptable. The only variables are the number of worksheets per workbook and
their names.
Is there a branch of Windows programming that supports this?
Many thanks.
--
admin4office_perl_programmer.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Automation of Excel to perform simple tasks on many workbooks.

Sub ABCD()
Dim srcPath as String
Dim destPath as STring
Dim sName as String
Dim bk as Workbook
Dim sh as Worksheet
srcPath = "C:\MyFolderxls\"
destPath = "C:\Myfoldercsv\"
sName = Dir(srcPath & "*.xls")
do
set bk = Workbooks.Open(srcPath & sName)
for each sh in bk.worksheets
sh.copy
activeWorkbook.SaveAs destPath & bk.Name & "_" & _
sh.Name & ".csv", fileformat:=xlCSV
activeWorkbook.Close Savechanges:=False
Next
bk.close SaveChanges:=False
sName = dir()
Loop while sname < ""
End Sub

How successful this is depends on what is in your sheets.

--
Regards,
Tom Ogilvy


"admin4office" wrote in message
...
I want to manipulate many Excel workbooks without having to open and

enter
commands in each of them. If I have a folder with 1000 Excel workbooks, I
would like to run a script that could open each, tell each to save its
worksheets as plain text, and then close each. I could then use Perl to
search or index the plain text files.
The sequence of commands seems to be predictable, and therefore
scriptable. The only variables are the number of worksheets per workbook

and
their names.
Is there a branch of Windows programming that supports this?
Many thanks.
--
admin4office_perl_programmer.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Automation of Excel to perform simple tasks on many workbooks.

To Tom Ogilvy,
Thanks very much! This is a great help.
Am I correct in assuming that this code is VBA? (Which I must obviously
learn.)
Would you run this program as an Excel macro, or from outside of Excel?

Thanks again,
admin4office_perl_programmer

"Tom Ogilvy" wrote:

Sub ABCD()
Dim srcPath as String
Dim destPath as STring
Dim sName as String
Dim bk as Workbook
Dim sh as Worksheet
srcPath = "C:\MyFolderxls\"
destPath = "C:\Myfoldercsv\"
sName = Dir(srcPath & "*.xls")
do
set bk = Workbooks.Open(srcPath & sName)
for each sh in bk.worksheets
sh.copy
activeWorkbook.SaveAs destPath & bk.Name & "_" & _
sh.Name & ".csv", fileformat:=xlCSV
activeWorkbook.Close Savechanges:=False
Next
bk.close SaveChanges:=False
sName = dir()
Loop while sname < ""
End Sub

How successful this is depends on what is in your sheets.

--
Regards,
Tom Ogilvy


"admin4office" wrote in message
...
I want to manipulate many Excel workbooks without having to open and

enter
commands in each of them. If I have a folder with 1000 Excel workbooks, I
would like to run a script that could open each, tell each to save its
worksheets as plain text, and then close each. I could then use Perl to
search or index the plain text files.
The sequence of commands seems to be predictable, and therefore
scriptable. The only variables are the number of worksheets per workbook

and
their names.
Is there a branch of Windows programming that supports this?
Many thanks.
--
admin4office_perl_programmer.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Automation of Excel to perform simple tasks on many workbooks.

It is VBA run from within Excel (as a macro). All code must be in a
workbook, so you would put this code in a workbook that is not in the folder
being processed.

--
Regards,
Tom Ogilvy

"admin4office" wrote in message
...
To Tom Ogilvy,
Thanks very much! This is a great help.
Am I correct in assuming that this code is VBA? (Which I must obviously
learn.)
Would you run this program as an Excel macro, or from outside of Excel?

Thanks again,
admin4office_perl_programmer

"Tom Ogilvy" wrote:

Sub ABCD()
Dim srcPath as String
Dim destPath as STring
Dim sName as String
Dim bk as Workbook
Dim sh as Worksheet
srcPath = "C:\MyFolderxls\"
destPath = "C:\Myfoldercsv\"
sName = Dir(srcPath & "*.xls")
do
set bk = Workbooks.Open(srcPath & sName)
for each sh in bk.worksheets
sh.copy
activeWorkbook.SaveAs destPath & bk.Name & "_" & _
sh.Name & ".csv", fileformat:=xlCSV
activeWorkbook.Close Savechanges:=False
Next
bk.close SaveChanges:=False
sName = dir()
Loop while sname < ""
End Sub

How successful this is depends on what is in your sheets.

--
Regards,
Tom Ogilvy


"admin4office" wrote in message
...
I want to manipulate many Excel workbooks without having to open

and
enter
commands in each of them. If I have a folder with 1000 Excel

workbooks, I
would like to run a script that could open each, tell each to save its
worksheets as plain text, and then close each. I could then use Perl

to
search or index the plain text files.
The sequence of commands seems to be predictable, and therefore
scriptable. The only variables are the number of worksheets per

workbook
and
their names.
Is there a branch of Windows programming that supports this?
Many thanks.
--
admin4office_perl_programmer.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Automation of Excel to perform simple tasks on many workbooks.

Thanks once again! This may save me an enormous amount of work.
Regards,
admin4office_perl_programmer

"Tom Ogilvy" wrote:

It is VBA run from within Excel (as a macro). All code must be in a
workbook, so you would put this code in a workbook that is not in the folder
being processed.

--
Regards,
Tom Ogilvy

"admin4office" wrote in message
...
To Tom Ogilvy,
Thanks very much! This is a great help.
Am I correct in assuming that this code is VBA? (Which I must obviously
learn.)
Would you run this program as an Excel macro, or from outside of Excel?

Thanks again,
admin4office_perl_programmer

"Tom Ogilvy" wrote:

Sub ABCD()
Dim srcPath as String
Dim destPath as STring
Dim sName as String
Dim bk as Workbook
Dim sh as Worksheet
srcPath = "C:\MyFolderxls\"
destPath = "C:\Myfoldercsv\"
sName = Dir(srcPath & "*.xls")
do
set bk = Workbooks.Open(srcPath & sName)
for each sh in bk.worksheets
sh.copy
activeWorkbook.SaveAs destPath & bk.Name & "_" & _
sh.Name & ".csv", fileformat:=xlCSV
activeWorkbook.Close Savechanges:=False
Next
bk.close SaveChanges:=False
sName = dir()
Loop while sname < ""
End Sub

How successful this is depends on what is in your sheets.

--
Regards,
Tom Ogilvy


"admin4office" wrote in message
...
I want to manipulate many Excel workbooks without having to open

and
enter
commands in each of them. If I have a folder with 1000 Excel

workbooks, I
would like to run a script that could open each, tell each to save its
worksheets as plain text, and then close each. I could then use Perl

to
search or index the plain text files.
The sequence of commands seems to be predictable, and therefore
scriptable. The only variables are the number of worksheets per

workbook
and
their names.
Is there a branch of Windows programming that supports this?
Many thanks.
--
admin4office_perl_programmer.






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
Compare Two Simple Workbooks & Remove Duplicate Rows Dave Excel Discussion (Misc queries) 9 July 25th 07 02:36 PM
How do I perform a global change within/across Excel workbooks? wilytdbear Excel Discussion (Misc queries) 2 July 25th 06 05:02 PM
Can I perform tasks on a closed Workbook Jeff Excel Programming 1 January 27th 05 06:13 PM
Outlook Automation, Deleting Tasks jjjustinnn Excel Programming 3 January 17th 04 07:11 PM
Excel automation and shared workbooks Matthew L. Butcher Excel Programming 0 December 4th 03 02:58 AM


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

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"