0

I have a problem with opening a created Access database with Python script using win32com because always is opened in read-only mode and no queries and macros run spitting a runtime error. I have read a lot on the internet, but I need help ... I don't found the solution ... This is my code, I think it's alright but:

nombreBD = 'path/database.accdb'
os.chmod(nombreBD, S_IWRITE)
objAccess = Dispatch("Access.Application")
objAccess.OpenCurrentDatabase (nombreBD, False)
objAccess.Visible = False
objAccess.DoCmd.RunMacro('Ejecutar')
objAccess.Visible = True
objAccess.CloseCurrentDatabase
objAccess.Application.Quit()  

I made this previous steps:

  1. User permissions to the file & folder
  2. Check my privacy in Office trust center: Link
    • Adding trust path
    • Allow script executions ...
  3. Read-only Access database turn off

When I open manually the desired database.accdb, it's okay, no problem and I can execute all but if I run it from Python Script, always is opened in read-only mode ... like if other process was active when the script call the file ... but I also check this and no access process is active and no .laccdb created.

enter image description here

Thank you in advance to all!

I'm running the script on Windows Server 2012.

Erik A
  • 31,639
  • 12
  • 42
  • 67
Mecaxis14
  • 131
  • 1
  • 3
  • When you launch the script, does that mean you can read data ok, and are able to read data from the tables? In other words, I would double check that your scripts ALSO fail if they attempt to only read data. And the screen shot is somewhat confusing since you saying when you launch Access, you have no problem. It is your scripts, and thus the screen shot of Access being read only does not make sense when you stated that access works fine. (unless the screen shot is the result of your script launching Access and it is displayed). – Albert D. Kallal Apr 22 '20 at 00:52
  • Exactly, the screenshot shows a script stop just when it opens Access database, it is the result of the execution. If I manually open the access, all Okay. If I use the script it opens the file in read-only, it gets to open Access but I can't run any query. I have tried accessing access to launch queries to a table, but being read-only an execution error jumps the same way. – Mecaxis14 Apr 22 '20 at 09:56
  • Anyone could help me please ? I'm stopped with this, and no solution found ... thank you in advance! – Mecaxis14 Apr 28 '20 at 14:51

0 Answers0