VBA to change extension

syedadnan

Access Lover
Local time
Tomorrow, 01:08
Joined
Mar 27, 2013
Messages
315
Regards,

Is there and possiblity to have a pop up message box asking for password when changing file extension from accdr to accdb ?
 
Just changing the extension? as in "rename filename" ? No.
 
Just changing the extension? as in "rename filename" ? No.

I am unable to get your reply ?.. however yes i want if someone changing the filename from accdr to accdb then it do not allows..
 
You can't rename a file that is in use.

You might be able to make a copy and then save that copy with a different extension.

I have not tested this. I will leave it up to you.
 
I just did a quick test.

I did copy a .mdb file while it was opened. I placed it into a different folder where it could be renamed.

Hope this helps.
 
Bearing in mind they would be able to do it outside the program anyway.

Are you trying to get someone to change the name of a file through your program?

Do you want to be able to detect whether they are renaming a file from ". accdr" to ". accdb" and only allow it if they enter the correct password?

Code:
 Public Sub renameFile(byVal oldName as String, byVal newName as String)
  Dim blDoRename as Boolean, strPassword as String

  blDoRename = True ' Default value to True

' If oldName contains ".accdr" and newName contains ".accdb" 
  If (instr(Lcase(oldName), ".accdr") > 0) AND (instr(Lcase(newName), ".accdb") > 0)

    strPassword =  InputBox("Input the password to complete the task")

' blDoRename is True if strPassword is correct else it is False
    blDoRename  = (strPassword = "yourPassword")

  Endif


' Only do rename if blDoRename is True
  if blDoRename = True Then Name oldName AS newName
End Sub
 

Users who are viewing this thread

Back
Top Bottom