Saving a cell name as a word doc
I have a list of cells in an excel spreadsheet that I want to use to create
separate word documents from a generic word document. right now I'm copying the cell name switching to Word opening file Save as and pasting the name. It doesn't take long but I've got over a thousand names to save as. Is there any way in Excel or Word that I can automate this process? |
Saving a cell name as a word doc
Say we have three names in A1 thru C1:
Firstfl Secondfl Thirdfl First put a dummy name in D1. The enter and run this macro: Sub Macro1() Dim s As String Dim i As Integer For i = 1 To 4 s = Cells(i, 1).Value fname = "C:\" & s & ".txt" ActiveWorkbook.SaveAs Filename:= _ fname, FileFormat:= _ xlText, CreateBackup:=False Next x = Shell("cmd.exe /c rename C:\*.txt *.doc", 1) End Sub The For loop creates a set of .txt files and the Shell command renames them as .doc. You will have three .doc files as a result. You can increase from three to any number. The extra dummy entry in needed to insure the last real entry gets renamed. -- Gary''s Student....gsnu02012006 "LDBlanes" wrote: I have a list of cells in an excel spreadsheet that I want to use to create separate word documents from a generic word document. right now I'm copying the cell name switching to Word opening file Save as and pasting the name. It doesn't take long but I've got over a thousand names to save as. Is there any way in Excel or Word that I can automate this process? |
Saving a cell name as a word doc
Thanks it works like a charm.
"Gary''s Student" wrote: Say we have three names in A1 thru C1: Firstfl Secondfl Thirdfl First put a dummy name in D1. The enter and run this macro: Sub Macro1() Dim s As String Dim i As Integer For i = 1 To 4 s = Cells(i, 1).Value fname = "C:\" & s & ".txt" ActiveWorkbook.SaveAs Filename:= _ fname, FileFormat:= _ xlText, CreateBackup:=False Next x = Shell("cmd.exe /c rename C:\*.txt *.doc", 1) End Sub The For loop creates a set of .txt files and the Shell command renames them as .doc. You will have three .doc files as a result. You can increase from three to any number. The extra dummy entry in needed to insure the last real entry gets renamed. -- Gary''s Student....gsnu02012006 "LDBlanes" wrote: I have a list of cells in an excel spreadsheet that I want to use to create separate word documents from a generic word document. right now I'm copying the cell name switching to Word opening file Save as and pasting the name. It doesn't take long but I've got over a thousand names to save as. Is there any way in Excel or Word that I can automate this process? |
Saving a cell name as a word doc
You are very welcome
-- Gary''s Student "LDBlanes" wrote: Thanks it works like a charm. "Gary''s Student" wrote: Say we have three names in A1 thru C1: Firstfl Secondfl Thirdfl First put a dummy name in D1. The enter and run this macro: Sub Macro1() Dim s As String Dim i As Integer For i = 1 To 4 s = Cells(i, 1).Value fname = "C:\" & s & ".txt" ActiveWorkbook.SaveAs Filename:= _ fname, FileFormat:= _ xlText, CreateBackup:=False Next x = Shell("cmd.exe /c rename C:\*.txt *.doc", 1) End Sub The For loop creates a set of .txt files and the Shell command renames them as .doc. You will have three .doc files as a result. You can increase from three to any number. The extra dummy entry in needed to insure the last real entry gets renamed. -- Gary''s Student....gsnu02012006 "LDBlanes" wrote: I have a list of cells in an excel spreadsheet that I want to use to create separate word documents from a generic word document. right now I'm copying the cell name switching to Word opening file Save as and pasting the name. It doesn't take long but I've got over a thousand names to save as. Is there any way in Excel or Word that I can automate this process? |
All times are GMT +1. The time now is 01:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com