views:

464

answers:

0

I am trying to change a filename extension in a macro for OpenOffice.

My files are named like "file.odt" and I need to transform this string to "file.pdf".

I use a macro that I have found on the Web but I have never written any line of basic code in my life ... However, the code is buggy and only works for 3 chars extensions (like ".doc"), so it breaks with things like ".docx".

Here is the code line :

cFile = Left( cFile, Len( cFile ) - 4 ) + ".pdf"

cFile being the filename.

I would like to do something like take cFile chars from 0 to the index of the last dot and append ".pdf".

Thanks!

Update : I finally found the solution.

cFile = Left( cFile, InStrRev( cFile, "." ) ) + "pdf"

BUT : You have to add

Option VBASupport 1

at the beginning of the file to make it work.