View Single Post
 
Old 11-13-2017, 02:23 AM
andrbea andrbea is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Nov 2017
Posts: 4
andrbea is on a distinguished road
Default

I have a macro file now (called creator1), with the lines

Sub CopyDocs()
'Graham Mayor - http://www.gmayor.com - Last updated - 13 Nov 2017
Dim oDoc As Document
Dim strName As String
Dim strExt As String
Dim strPath As String
Dim iNum As Integer
Dim fso As Object
Set oDoc = ActiveDocument
If Not oDoc.Path = "" Then
strExt = Mid(oDoc.Name, InStrRev(oDoc.Name, Chr(46)))
If Len(oDoc.Name) = 3 + Len(strExt) And Mid(oDoc.Name, 3, 1) = "1" Then
strPath = oDoc.Path & Chr(92)
strName = Left(oDoc.Name, 2)
Set fso = CreateObject("Scripting.FileSystemObject")
For iNum = 2 To InputBox("Enter the total number of documents to be created", , 35)
fso.CopyFile strPath & strName & "1" & strExt, strPath & strName & CStr(iNum) & strExt
Next iNum
Else
MsgBox "Filename in the wrong format!"
End If
Else
MsgBox "Document not saved."
End If
MsgBox iNum - 1 & " copies created"
lbl_Exit:
Set oDoc = Nothing
Set fso = Nothing
Exit Sub
End Sub

If I create 1st file, save it as XG1, then execute the macro (it shows up in the dropdown menu, as creator1), the result, in the word file is that the content of the macro just gets written in another file (the code itself)
what am I doing wrong?

Tks for writing the macro by the way.
But how do I get it to work?

I used the tab view - record macro - pasted your code - stop recording macro
Reply With Quote