![]() |
#3
|
|||
|
|||
![]()
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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
JonniBravo | Word | 6 | 03-13-2017 11:35 AM |
ics file - issue with times | Officer_Bierschnitt | Excel Programming | 0 | 10-06-2016 01:52 AM |
![]() |
klpw | Excel Programming | 2 | 12-24-2015 12:31 AM |
![]() |
brmveen | Word VBA | 2 | 11-04-2015 12:51 AM |
![]() |
zatlas1 | Office | 8 | 04-28-2012 02:37 PM |