ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Wanting to automate: Change name of several excel documents (https://www.excelbanter.com/excel-discussion-misc-queries/212954-wanting-automate-change-name-several-excel-documents.html)

Silvie

Wanting to automate: Change name of several excel documents
 
I have several excel documents (templates) all with the name
xxx_Testprotocol1, xxx_Testprotocol2 etc. For each test campaign I need to
replace the xxx at the beginning with the name of the testcampaign e.g.
RC27_Testprotocol1.

Is there a way of automating this since doing it manually is quite time
consuming.

Cheers
Silvie

joel

Wanting to automate: Change name of several excel documents
 
Use code below. Read comments and change Folder as required.

Sub MakeCopy()

Folder = "c:\temp\"
'get all xlt files
TestCampaign = InputBox("Enter test Campaign : ")
FName = Dir(Folder & "*.xlt")
Do While FName < ""
'make sure xlt files start with XXX
If UCase(Left(FName, 3)) = "XXX" Then
'remove extension
BaseName = Left(FName, InStr(FName, ".") - 1)
'remove three XX at the geginning of name
BaseName = Mid(BaseName, 4)
'copy file and change extension from xlt to xls
FileCopy Source:=Folder & FName, _
Destination:=Folder & TestCampaign & BaseName & "xls"
End If
FName = Dir()
Loop
End Sub


"Silvie" wrote:

I have several excel documents (templates) all with the name
xxx_Testprotocol1, xxx_Testprotocol2 etc. For each test campaign I need to
replace the xxx at the beginning with the name of the testcampaign e.g.
RC27_Testprotocol1.

Is there a way of automating this since doing it manually is quite time
consuming.

Cheers
Silvie



All times are GMT +1. The time now is 07:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com