Solved! Go to Solution.
Solved by Vladimir.Ananyev. Go to Solution.
You may consider the huge set of methods in the .NET String class to change filename.
Look at these links:
String Class
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.strings.aspx?cs-save-lang=1&cs-lang=vb...
Strings in Visual Basic
http://msdn.microsoft.com/en-us/library/hzcd8ze0.aspx
You may use
ThisDoc.Document.SaveAs(NewFileNameAndExtension , SaveCopyAs)
method to save the file with another filename.
Thanks for the quick reply and info. Now, that I have a basic understanding of strings how do I tell my renamed file what path to take? I want my renamed file to save to a certain directory.
Assume
1) the new filename is MyNewFile.ipt
2) you want to save your renamed file to the existing folder d:\AAA\BBB\CCC\DDD
then your rule could be similar to the following:
'new filename dim Filename as string = "MyNewFile.ipt" 'target folder path dim DirName as string = "d:\AAA\BBB\CCC\DDD" 'now you may create the full filename dim FullFilename as string = DirName & "\" & Filename 'save file ThisDoc.Document.SaveAs(FullFilename , False)
See also System.IO.Path class details.
Very useful if you need to perform operations on strings that contain file or directory path information.
http://msdn.microsoft.com/en-us/library/system.io.path.aspx
Thanks that worked but how do I delete the old folder once my file has been moved?
My advice - use .NET System.IO namespace objects.
In this particular case - Directory.Delete(...) method
http://msdn.microsoft.com/en-us/library/system.io.aspx