Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Convert from "xls" to "xlsm" format

Hi all, I am looking for macro which convert all "xls" format files
into "xlsm" format in the specified folder.
Macro should also pop up message boxes on conditions (see below)
1 - If all files in folder already in in "xlsm" formate then macro
should pop up message box saying "No file needed to Convert"
2 - When macro finish converting files from "xls" to "xlsm" format
then message box come up saying " 85 files been converted " (85 is
given as example here that how many files have been converted - macro
should workout how many files has been converted and put number on
message box)
3 - if in folder some files are already in "xlsm" format and some are
in "xls" then after converting "xls" message box come up saying " 3
files not converted & vbnewline & 12 files been converted" (3 and 12
are given as examples which means No. of files - again macro should
workout how many files converted and how many not converted and put
numbers on message box)
Please can any friend help me on this
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Convert from "xls" to "xlsm" format

You could run a macro, below. Change the path to where you have the files stored. With Excel 2007,
you have a few options - I'm showing how to save files that may have macros or other code... it is
left as your task to do the counting and messages...


HTH,
Bernie Deitrick
MS Excel MVP


Sub TrandformAllXLSFilesToXLSM()


Dim myPath As String


myPath = "C:\Excel\"
WorkFile = Dir(myPath & "*.xls")


Do While WorkFile < ""
If Right(WorkFile, 4) < "xlsm" Then
Workbooks.Open FileName:=myPath & WorkFile
ActiveWorkbook.SaveAs FileName:= _
myPath & WorkFile & "m", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
ActiveWorkbook.Close
End If
WorkFile = Dir()
Loop
End Sub



--
HTH,
Bernie
MS Excel MVP


"K" wrote in message
...
Hi all, I am looking for macro which convert all "xls" format files
into "xlsm" format in the specified folder.
Macro should also pop up message boxes on conditions (see below)
1 - If all files in folder already in in "xlsm" formate then macro
should pop up message box saying "No file needed to Convert"
2 - When macro finish converting files from "xls" to "xlsm" format
then message box come up saying " 85 files been converted " (85 is
given as example here that how many files have been converted - macro
should workout how many files has been converted and put number on
message box)
3 - if in folder some files are already in "xlsm" format and some are
in "xls" then after converting "xls" message box come up saying " 3
files not converted & vbnewline & 12 files been converted" (3 and 12
are given as examples which means No. of files - again macro should
workout how many files converted and how many not converted and put
numbers on message box)
Please can any friend help me on this



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Convert from "xls" to "xlsm" format

Thanks Bernie , your code works perfect just small question that how
can i kill or delete the old format files because i only want new
formated files in the folder
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Convert from "xls" to "xlsm" format

Add in the Kill after you've opened and saved the file:


If Right(WorkFile, 4) < "xlsm" Then
Workbooks.Open FileName:=myPath & WorkFile
ActiveWorkbook.SaveAs FileName:= _
myPath & WorkFile & "m", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
ActiveWorkbook.Close
Kill myPath & WorkFile
End If

--
HTH,
Bernie
MS Excel MVP


"K" wrote in message
...
Thanks Bernie , your code works perfect just small question that how
can i kill or delete the old format files because i only want new
formated files in the folder



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Convert from "xls" to "xlsm" format

On Sep 5, 3:22*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
* *Add in the Kill after you've opened and saved the file:

If Right(WorkFile, 4) < "xlsm" Then
* * * Workbooks.Open FileName:=myPath & WorkFile
* * * ActiveWorkbook.SaveAs FileName:= _
* * * * * * myPath & WorkFile & "m", FileFormat:= _
* * * * * * xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
* * * ActiveWorkbook.Close
* * *Kill myPath & WorkFile
* End If

--
HTH,
Bernie
MS Excel MVP

"K" wrote in message

...



Thanks Bernie , your code works perfect just small question that how
can i kill or delete the old format files because i only want new
formated files in the folder- Hide quoted text -


- Show quoted text -


thats brilliant thanks lot. just last question sorry to be pain. how
can i convert them back to "xls" . just for knowledge


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Convert from "xls" to "xlsm" format



thats brilliant thanks lot. just last question sorry to be pain. how
can i convert them back to "xls" . just for knowledge



You would need to change the name to remove the m from the end, and change

xlOpenXMLWorkbookMacroEnabled

to.... some other value - I don't have the list available, but it should be readily apparent when
you look at the list, for XL97 to 2003 format. Sorry for being so cryptic, but I don't have 2007
readily available.

HTH,
Bernie
MS Excel MVP



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Convert from "xls" to "xlsm" format

On Sep 5, 3:03*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
You could run a macro, below. *Change the path to where you have the files stored. *With Excel 2007,
you have a few options - I'm showing how to save files that may have macros or other code... it is
left as your task to do the counting and messages...

HTH,
Bernie Deitrick
MS Excel MVP

Sub TrandformAllXLSFilesToXLSM()

Dim myPath As String

myPath = "C:\Excel\"
WorkFile = Dir(myPath & "*.xls")

Do While WorkFile < ""
* *If Right(WorkFile, 4) < "xlsm" Then
* * * Workbooks.Open FileName:=myPath & WorkFile
* * * ActiveWorkbook.SaveAs FileName:= _
* * * * * * myPath & WorkFile & "m", FileFormat:= _
* * * * * * xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
* * * ActiveWorkbook.Close
* *End If
* *WorkFile = Dir()
Loop
End Sub

--
HTH,
Bernie
MS Excel MVP

"K" wrote in message

...



Hi all, I am looking for macro which convert all "xls" format files
into "xlsm" format in the specified folder.
Macro should also pop up message boxes on conditions (see below)
1 - If all files in folder already in in "xlsm" formate then macro
should pop up message box saying "No file needed to Convert"
2 - When macro finish converting files from "xls" to "xlsm" format
then message box come up saying " 85 files been converted " *(85 is
given as example here that how many files have been converted - macro
should workout how many files has been converted and put number on
message box)
3 - if in folder some files are already in "xlsm" format and some are
in "xls" then after converting "xls" message box come up saying " 3
files not converted & vbnewline & 12 files been converted" (3 and 12
are given as examples which means No. of files - again macro should
workout how many files converted and how many not converted and put
numbers on message box)
Please can any friend help me on this- Hide quoted text -


- Show quoted text -


Thanks, just a question that how can i delete or kill old format
files as i need only new formated files in the folder
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Convert from "xls" to "xlsm" format

See
http://www.labnol.org/software/bulk-...7-format/4291/

I test it and it is working Ok

--

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


"K" wrote in message ...
Hi all, I am looking for macro which convert all "xls" format files
into "xlsm" format in the specified folder.
Macro should also pop up message boxes on conditions (see below)
1 - If all files in folder already in in "xlsm" formate then macro
should pop up message box saying "No file needed to Convert"
2 - When macro finish converting files from "xls" to "xlsm" format
then message box come up saying " 85 files been converted " (85 is
given as example here that how many files have been converted - macro
should workout how many files has been converted and put number on
message box)
3 - if in folder some files are already in "xlsm" format and some are
in "xls" then after converting "xls" message box come up saying " 3
files not converted & vbnewline & 12 files been converted" (3 and 12
are given as examples which means No. of files - again macro should
workout how many files converted and how many not converted and put
numbers on message box)
Please can any friend help me on this

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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Excel VBA to convert "dd.MM.yy" text to "dd/MM/yyyy" format date? Paul J[_2_] Excel Programming 4 July 11th 07 11:32 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Convert "Month" to "MonthName" format from db to PivotTable Billabong Excel Programming 1 August 25th 04 09:14 AM


All times are GMT +1. The time now is 10:18 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"