Sub rename_()

ExcelDennis

New Member
Joined
Aug 12, 2013
Messages
25
Hi,

I want to rename PT63MW-2012 Ocena Roczna dla Joanna Oręczuk-18159.pdf to 2570657_Perf_doc_2012_Succesfactor_1335.pdf

PT63MW-2012 Ocena Roczna dla Joanna Oręczuk-18159.pdf is in cell A1
2570657_Perf_doc_2012_Succesfactor_1335.pdf is in cell B1

File is in C\temp\

I use following VBA script

Sub rename_()
Dim OldName As String, NewName As String, mydir As String

mydir = "C:\Temp"

With Worksheets("Sheet1")
OldName = .Range("A1").Value
NewName = .Range("B1").Value
End With

Name mydir & OldName As mydir & NewName
End Sub

After running i do get Run-time error '53': File not Found. I guess because of the special Character ę in the name.

Pls help me with changing the code so i can rename the file. (need to rename over 15000 files with special characters)

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I imagine it's just because you don't have a backslash on the end of the path. Try using:

Code:
mydir = "C:\Temp\"
 
Upvote 0
Hi Sir,

Did changed that in the code but still same error, when I leave the special character out my script works

Do u have other suggestions

Thanks

I imagine it's just because you don't have a backslash on the end of the path. Try using:

Code:
mydir = "C:\Temp\"
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top