patgenn123 Posted December 2, 2009 Report Share Posted December 2, 2009 Hello, This should be simple. I am trying to rename a file. In my macro, I am declaring a variable to be taken from the window title into %T2%. Later I want to rename the file from E:\Personal Folders\RenderedPage.pdf to %T2%.pdf after the file was moved TO E:\Personal Folders using the Macro Express "Change Directory/Folder" function. It works up until it has to rename the file. I keep on getting an error "There are one or more invalid cahracters in the file path. I am not seeing it. Where? Essentially I am changing it from: E:\Personal Folders\RenderedPage.pdf to E:\Personal Folders\%T2%.pdf and %T2% has already been grabbed from the window title. Help? Pat Quote Link to comment Share on other sites More sharing options...
rberq Posted December 2, 2009 Report Share Posted December 2, 2009 For debugging, temporarily put a Text Box Display command before your rename attempt, to show you the value of %T2% that is being used. Bracket the T2 value with special characters so you can see whether there are trailing blanks; for example in the body of the text box put >>>%T2%<<<. Quote Link to comment Share on other sites More sharing options...
patgenn123 Posted December 3, 2009 Author Report Share Posted December 3, 2009 Thanks Bob, I found the problem. The window title had a "|" in it. I replaced it with space, but it is still not renaming my file. I don't get the error message anymore, but it's not renaming my file. Pat Quote Link to comment Share on other sites More sharing options...
rberq Posted December 3, 2009 Report Share Posted December 3, 2009 If the file name now has an embedded space, I wonder if you have to enclose the whole thing in "quotes" Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted December 4, 2009 Report Share Posted December 4, 2009 I would check the complete filepath (not just %T2%) with a Text Box immediately prior to renaming. I always do that with file renaming until I'm sure it works OK, to avoid potential disaster. I think I normally would make the full filepath a new variable, say %T3% which I would use in the renaming. It would show all errors during the Text Box check. A fave mistake is to miss off the file extension of the fabricated filename. The file will be renamed but appear in an unexpected place in Explorer's listing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.