Re: Convert files from wr1. to xls

Robert F

New Member
Joined
Dec 10, 2009
Messages
1
Re: Convert files from wr1. to xls

Re: Convert files from wr1. to xls

I copied the following from the archive of February 14, 2002
Does anyone have the code that was sent to D so I can convert my WR1 files to XLS ? (My WR1 files are files I created from Lotus Symphony in the mid 1980's.... Thanks

Posted by DK on February 14, 2002 9:31 AM




Here's code that will open all files in a specified folder and save them as Excel format. Let me know if you have any problems,
D
Option Explicit
Sub ConvertFiles()
'All WR1 files should be in the same folder in order for
'this code to work. There should be no other files other than
'the ones you want to convert.
Dim strFolder As String, lngFile As Long
'Change this to the folder containing the Wr1 files
strFolder = "C:\temp\wr1 files"
With Application.FileSearch
.NewSearch
.FileType = msoFileTypeAllFiles
.LookIn = strFolder
.Execute

For lngFile = 1 To .FoundFiles.Count
'Here's where you need to put the code to open the file and convert it
Workbooks.Open .FoundFiles(lngFile)
ActiveWorkbook.SaveAs "C:\temp\converted files\file" & lngFile, xlExcel7
ActiveWorkbook.Close
Next lngFile
End With
End Sub
 
Re: Convert files from wr1. to xls

I'm also trying to convert a large number of files from a WR1 format to Excel 2010. When I try to run the code below from Excel 2010 VB, I get a run-time 445 error. I think the issue is that the FileSearch command no longer appears to be available with 2010. I'm new to VB, particularly in Excel. How would I modify DK's original code so that it doesn't rely on the FileSearch command? Thank you!

Re: Convert files from wr1. to xls

I copied the following from the archive of February 14, 2002
Does anyone have the code that was sent to D so I can convert my WR1 files to XLS ? (My WR1 files are files I created from Lotus Symphony in the mid 1980's.... Thanks

Posted by DK on February 14, 2002 9:31 AM




Here's code that will open all files in a specified folder and save them as Excel format. Let me know if you have any problems,
D
Option Explicit
Sub ConvertFiles()
'All WR1 files should be in the same folder in order for
'this code to work. There should be no other files other than
'the ones you want to convert.
Dim strFolder As String, lngFile As Long
'Change this to the folder containing the Wr1 files
strFolder = "C:\temp\wr1 files"
With Application.FileSearch
.NewSearch
.FileType = msoFileTypeAllFiles
.LookIn = strFolder
.Execute

For lngFile = 1 To .FoundFiles.Count
'Here's where you need to put the code to open the file and convert it
Workbooks.Open .FoundFiles(lngFile)
ActiveWorkbook.SaveAs "C:\temp\converted files\file" & lngFile, xlExcel7
ActiveWorkbook.Close
Next lngFile
End With
End Sub
 
Upvote 0
Re: Convert files from wr1. to xls

Try this...

Code:
[color=darkblue]Sub[/color] ConvertFiles()
    [color=green]'All WR1 files should be in the same folder in order for[/color]
    [color=green]'this code to work. There should be no other files other than[/color]
    [color=green]'the ones you want to convert.[/color]
    [color=darkblue]Dim[/color] strFolder [color=darkblue]As[/color] [color=darkblue]String[/color], strFile [color=darkblue]As[/color] [color=darkblue]String[/color], strExt [color=darkblue]As[/color] [color=darkblue]String[/color], counter [color=darkblue]As[/color] [color=darkblue]Long[/color]
    [color=green]'File extention to convert from[/color]
    strExt = ".wr1"
    [color=green]'Change this to the folder containing the Wr1 files[/color]
    strFolder = "C:\temp\wr1 files"
    [color=darkblue]If[/color] Right(strFolder, 1) <> Application.PathSeparator [color=darkblue]Then[/color] strFolder = strFolder & Application.PathSeparator
    strFile = Dir(strFolder & "*" & strExt)
    Application.ScreenUpdating = [color=darkblue]False[/color]
        [color=darkblue]Do[/color] [color=darkblue]While[/color] Len(strFile)
            [color=green]'Here's where you need to put the code to open the file and convert it[/color]
            Workbooks.Open strFoleder & strFile
            [color=green]'Destination to save the converted files[/color]
            ActiveWorkbook.SaveAs "C:\Test\" & Replace(strFile, strExt, ""), FileFormat:=xlExcel7
            ActiveWorkbook.Close
            counter = counter + 1
            strFile = Dir()
        [color=darkblue]Loop[/color]
    Application.ScreenUpdating = [color=darkblue]True[/color]
    MsgBox counter & " files convered. ", , "Conversion Complete"
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
Re: Convert files from wr1. to xls

Thanks for the reply. No luck. I get a Run-Time 1004 error, "Application-defined or object-defined error".
 
Upvote 0
Re: Convert files from wr1. to xls

Did you set your source folder...
strFolder = "C:\temp\wr1 files"

And your destination folder...
ActiveWorkbook.SaveAs "C:\Test\" & Replace...

Otherwise, can you show your code and what line is highlighted when you debug the code?
 
Last edited:
Upvote 0
Re: Convert files from wr1. to xls

Thanks for the reply. This has been a big help. I should have taken a closer look before trying to run the code. There was a minor typo in the Workbooks.Open statement - "strfoLEder" should be "StrFolder". After I made the change everything ran smoothly. Now I just need to figure out what these .wr1 files actually are! Everything just shows up as symbols in Excel 2010. Thanks again for all of your help!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top