close

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?

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 = quot;C:\quot; amp; s amp; quot;.txtquot;
ActiveWorkbook.SaveAs Filename:= _
fname, FileFormat:= _
xlText, CreateBackup:=False
Next
x = Shell(quot;cmd.exe /c rename C:\*.txt *.docquot;, 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....gsnu02012006quot;LDBlanesquot; wrote:

gt; I have a list of cells in an excel spreadsheet that I want to use to create
gt; separate word documents from a generic word document.
gt;
gt; right now I'm copying the cell name switching to Word opening file Save as
gt; and pasting the name.
gt;
gt; It doesn't take long but I've got over a thousand names to save as. Is
gt; there any way in Excel or Word that I can automate this process?

Thanks it works like a charm.

quot;Gary''s Studentquot; wrote:

gt; Say we have three names in A1 thru C1:
gt;
gt; Firstfl
gt; Secondfl
gt; Thirdfl
gt;
gt; First put a dummy name in D1. The enter and run this macro:
gt;
gt;
gt; Sub Macro1()
gt; Dim s As String
gt; Dim i As Integer
gt; For i = 1 To 4
gt; s = Cells(i, 1).Value
gt; fname = quot;C:\quot; amp; s amp; quot;.txtquot;
gt; ActiveWorkbook.SaveAs Filename:= _
gt; fname, FileFormat:= _
gt; xlText, CreateBackup:=False
gt; Next
gt; x = Shell(quot;cmd.exe /c rename C:\*.txt *.docquot;, 1)
gt; End Sub
gt;
gt; The For loop creates a set of .txt files and the Shell command renames them
gt; as .doc. You will have three .doc files as a result.
gt;
gt;
gt; You can increase from three to any number. The extra dummy entry in needed
gt; to insure the last real entry gets renamed.
gt; --
gt; Gary''s Student....gsnu02012006
gt;
gt;
gt; quot;LDBlanesquot; wrote:
gt;
gt; gt; I have a list of cells in an excel spreadsheet that I want to use to create
gt; gt; separate word documents from a generic word document.
gt; gt;
gt; gt; right now I'm copying the cell name switching to Word opening file Save as
gt; gt; and pasting the name.
gt; gt;
gt; gt; It doesn't take long but I've got over a thousand names to save as. Is
gt; gt; there any way in Excel or Word that I can automate this process?

You are very welcome
--
Gary''s Studentquot;LDBlanesquot; wrote:

gt; Thanks it works like a charm.
gt;
gt; quot;Gary''s Studentquot; wrote:
gt;
gt; gt; Say we have three names in A1 thru C1:
gt; gt;
gt; gt; Firstfl
gt; gt; Secondfl
gt; gt; Thirdfl
gt; gt;
gt; gt; First put a dummy name in D1. The enter and run this macro:
gt; gt;
gt; gt;
gt; gt; Sub Macro1()
gt; gt; Dim s As String
gt; gt; Dim i As Integer
gt; gt; For i = 1 To 4
gt; gt; s = Cells(i, 1).Value
gt; gt; fname = quot;C:\quot; amp; s amp; quot;.txtquot;
gt; gt; ActiveWorkbook.SaveAs Filename:= _
gt; gt; fname, FileFormat:= _
gt; gt; xlText, CreateBackup:=False
gt; gt; Next
gt; gt; x = Shell(quot;cmd.exe /c rename C:\*.txt *.docquot;, 1)
gt; gt; End Sub
gt; gt;
gt; gt; The For loop creates a set of .txt files and the Shell command renames them
gt; gt; as .doc. You will have three .doc files as a result.
gt; gt;
gt; gt;
gt; gt; You can increase from three to any number. The extra dummy entry in needed
gt; gt; to insure the last real entry gets renamed.
gt; gt; --
gt; gt; Gary''s Student....gsnu02012006
gt; gt;
gt; gt;
gt; gt; quot;LDBlanesquot; wrote:
gt; gt;
gt; gt; gt; I have a list of cells in an excel spreadsheet that I want to use to create
gt; gt; gt; separate word documents from a generic word document.
gt; gt; gt;
gt; gt; gt; right now I'm copying the cell name switching to Word opening file Save as
gt; gt; gt; and pasting the name.
gt; gt; gt;
gt; gt; gt; It doesn't take long but I've got over a thousand names to save as. Is
gt; gt; gt; there any way in Excel or Word that I can automate this process?

全站熱搜
創作者介紹
創作者 software 的頭像
software

software

software 發表在 痞客邦 留言(0) 人氣()