PDA

View Full Version : [SOLVED:] macro to convert all word files to excel from a folder



aravindhan_3
07-08-2010, 08:18 AM
Hi,

I would appreciate very much if you could help me on this..

I have 100 word files in a folder c:/word_folder
open each file copy to a new excel file make it bold & add some borders( this can be generated using record macro) and save as an excel file, so all the 100 word file will be saved in another folder c:/excel_folder as 100 excel file.


Thanks and regards
Arvind

Bob Phillips
07-08-2010, 09:37 AM
Sub GetThem()
Dim mpWord As Object
Dim mpDoc As Object
Dim mpNext As Long
Dim mpStart As Boolean
Dim mpData As String
Dim mpDirectory As String
Dim mpFilename As String
With Application
With .FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = -1 Then
mpDirectory = .SelectedItems(1)
Set mpWord = CreateObject("Word.Application")
mpWord.Visible = True
mpFilename = Dir(mpDirectory & Application.PathSeparator & "*.doc")
Do
Set mpDoc = mpWord.Documents.Open(mpDirectory & Application.PathSeparator & mpFilename)
mpData = ""
With mpDoc
mpNext = mpNext + 1
Worksheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = "File " & mpNext
.Range(.Content.Start, .Content.End).Copy
ActiveSheet.Paste
.Close
End With
mpFilename = Dir
Loop Until mpFilename = ""
End If
End With
End With
mpWord.Quit
Set mpWord = Nothing
End Sub

aravindhan_3
07-08-2010, 10:26 PM
thanks for your help,
is it possible to make as new excel file instead of excel sheet?

if there are 100 word files then there should be 100 excel files

thanks again for your quick help...