Try this

Sub CreateWordDocs()

    Dim xsht As Worksheet
    Dim rng As Range
    Dim lngLoop As Integer

    Set xsht = ActiveWorkbook.Worksheets("Sheet1")
    lngLoop = xsht.Cells(Rows.Count, 3).End(xlUp).Row

    If lngLoop > 1 Then
        With CreateObject("Word.Application")
            .Visible = True
            For Each rng In xsht.Range("C2:C" & lngLoop)
                With .Documents.Add
                    .SaveAs "F:\Folder\" & rng.Value, 16
                    .Close 0
                End With
            Next rng
            .Quit 0
        End With
    End If

End Sub

Regards,

Sam Mathai Chacko

On Wed, Mar 14, 2012 at 9:17 PM, Patil MG <mailpati...@gmail.com> wrote:

> Dear Sir
>
> I can able to create Notepad files , but i getting following error when
> trying to create word files
> Run Time Error
> User Defined is not found
>
>
> On Tue, Mar 13, 2012 at 4:39 PM, BNS kumar <chimir...@gmail.com> wrote:
>
>> Hi,
>>
>> check this out
>>
>> Sub CreateWordDocs()
>>     ' add a reference to the Word-library
>>     ' this is for creating number word Documents and renaming them with
>> file names mentioned in 'C' column
>>     ' this code doesn't write any content, it just creates word documents
>> and saves them
>>
>>     Dim newapp As Word.Application
>>     Dim newDoc As Word.Document
>>     Dim xsht As Worksheet
>>     Dim filename As Range
>>     Dim xcell As Range
>>     Dim LastCell As Range
>>     Dim i As Integer
>>
>>     Set xsht = ActiveWorkbook.Sheets("Sheet1")
>>     Set LastCell = xsht.Range("C65000").End(xlUp)
>>
>>     If Not LastCell.Row > 1 Then Exit Sub 'condition to check whether
>> filename is entered or not
>>
>>     Set filename = xsht.Range("C2:C" & LastCell.Row)
>>
>>     Set newapp = CreateObject("word.application")
>>     newapp.Visible = True
>>
>>     For Each xcell In filename
>>
>>         Set newDoc = newapp.Documents.Add
>>
>>         With newDoc
>>             .SaveAs ("D:\New Folder\" & xcell.Value & ".doc") 'instead of
>> "D;\New Folder", you can give your own path
>>             .Close
>>         End With
>>         Set newDoc = Nothing
>>     Next xcell
>>
>>     newapp.Quit
>>     Set newDoc = Nothing
>>     Set newapp = Nothing
>>
>> End Sub
>>
>>
>> ------------------------------------------------------------------------------
>>
>> Sub CreateNotePads()
>>
>>     'this with create notepads without writing any content in them
>>
>>     Dim fs As Object
>>     Dim a As Object
>>     Dim xsht As Worksheet
>>     Dim filename As Range
>>     Dim xcell As Range
>>     Dim LastCell As Range
>>     Dim i As Integer
>>
>>     Set xsht = Sheets("Sheet1")
>>     Set LastCell = xsht.Range("C65000").End(xlUp)
>>
>>     If Not LastCell.Row > 1 Then Exit Sub 'condition to check whether
>> filename is entered or not
>>
>>     Set filename = xsht.Range("C2:C" & LastCell.Row)
>>
>>     Set fs = CreateObject("scripting.filesystemobject")
>>
>>     For Each xcell In filename
>>
>>         Set a = fs.createtextfile("D:\New Folder\" & xcell.Value &
>> ".txt", True) 'give your own path
>>
>>         Set a = Nothing
>>     Next xcell
>>
>>
>> End Sub
>>
>>
>> Regards
>> Kumar
>>
>>
>> On Tue, Mar 13, 2012 at 2:08 PM, Patil MG <mailpati...@gmail.com> wrote:
>>
>>> Hi All
>>>
>>> can any one help me plzzzz......its very urgent,,,,,,,,,,,,,,,
>>>
>>>
>>> On Mon, Mar 12, 2012 at 12:52 PM, Patil MG <mailpati...@gmail.com>wrote:
>>>
>>>> Dear Experts,
>>>>
>>>> I have to create 'N' number of empty files of word and note pad files,
>>>> this word will long time to do can any one help to write a macro where in
>>>> which i can create empty word files or note pad files by running the macro,
>>>> my files will be listed in excel file (please refer the attached Excel
>>>> sheets
>>>>
>>>> --
>>>> Thank You
>>>> Patil MG
>>>>
>>>>
>>>>  --
>>>> FORUM RULES (986+ members already BANNED for violation)
>>>>
>>>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>>>> will not get quick attention or may not be answered.
>>>>
>>>> 2) Don't post a question in the thread of another member.
>>>>
>>>> 3) Don't post questions regarding breaking or bypassing any security
>>>> measure.
>>>>
>>>> 4) Acknowledge the responses you receive, good or bad.
>>>>
>>>> 5) Cross-promotion of, or links to, forums competitive to this forum in
>>>> signatures are prohibited.
>>>>
>>>> NOTE : Don't ever post personal or confidential data in a workbook.
>>>> Forum owners and members are not responsible for any loss.
>>>>
>>>>
>>>> ------------------------------------------------------------------------------------------------------
>>>> To post to this group, send email to excel-macros@googlegroups.com
>>>>
>>>
>>>
>>>
>>> --
>>> Thank You
>>> Patil MG
>>> 9663374848
>>>
>>> Life is Very Beautiful!!!
>>> ¨`•.•´¨)  Always
>>> `•.¸(¨`•.•´¨)  Keep
>>> (¨`•.•´¨)¸•´     Smiling!
>>>   `•.¸.•´.
>>>
>>>  --
>>> FORUM RULES (986+ members already BANNED for violation)
>>>
>>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>>> will not get quick attention or may not be answered.
>>>
>>> 2) Don't post a question in the thread of another member.
>>>
>>> 3) Don't post questions regarding breaking or bypassing any security
>>> measure.
>>>
>>> 4) Acknowledge the responses you receive, good or bad.
>>>
>>> 5) Cross-promotion of, or links to, forums competitive to this forum in
>>> signatures are prohibited.
>>>
>>> NOTE : Don't ever post personal or confidential data in a workbook.
>>> Forum owners and members are not responsible for any loss.
>>>
>>>
>>> ------------------------------------------------------------------------------------------------------
>>> To post to this group, send email to excel-macros@googlegroups.com
>>>
>>
>>  --
>> FORUM RULES (986+ members already BANNED for violation)
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>>
>> 2) Don't post a question in the thread of another member.
>>
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>>
>> 4) Acknowledge the responses you receive, good or bad.
>>
>> 5) Cross-promotion of, or links to, forums competitive to this forum in
>> signatures are prohibited.
>>
>> NOTE : Don't ever post personal or confidential data in a workbook. Forum
>> owners and members are not responsible for any loss.
>>
>>
>> ------------------------------------------------------------------------------------------------------
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>
>
>
> --
> Thank You
> Patil MG
> 9663374848
>
> Life is Very Beautiful!!!
> ¨`•.•´¨)  Always
> `•.¸(¨`•.•´¨)  Keep
> (¨`•.•´¨)¸•´     Smiling!
>   `•.¸.•´.
>
>  --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>



-- 
Sam Mathai Chacko

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to