Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 11-13-2017, 02:23 AM
andrbea andrbea is offline Save the same file with different name 35 times Windows 7 64bit Save the same file with different name 35 times Office 2010 64bit
Novice
Save the same file with different name 35 times
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Save the same file with different name 35 times Save document multiple times with date as filename 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
Save the same file with different name 35 times vba code for folder name, subfolder directory, file name & revision times klpw Excel Programming 2 12-24-2015 12:31 AM
Save the same file with different name 35 times save dialog box promt doesn't save file brmveen Word VBA 2 11-04-2015 12:51 AM
Save the same file with different name 35 times error: You are attempting to save a file format that is blocked by file block setting zatlas1 Office 8 04-28-2012 02:37 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:38 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft