The file is locked - Excel and VBA

Asked

Viewed 227 times

-1

I have an excel spreadsheet with userform to control a database that is also in excel, this database for having many accesses is shared, but today I saw that VBA does not get along very well with shared files, While saving the file I received error that the file is locked. That was the command:

Private Sub Sair_Click()

    Unload Me

    Workbooks("database.xlsx").Close savechanges:=True
    Workbooks("Controle de Contratos-2020.xlsb").Close savechanges:=True
    Application.DisplayAlerts = True 'reativar alertas


End Sub

The shared worksheet is this database.

1 answer

2

Excel is not a software made to be used as a database. It has several problems with sharing, cannot be accessed by two clients at the same time, can generate numerous conflicts when saving the files. My suggestion is to migrate this spreadsheet to a database in Access because it will be the one that you will have a better support to continue using the vba.

  • Alex, I am totally naive in database, is there any way to write the data there without using too much SQL? Because my weak is really the SQL part

  • 2

    Have you worked with Access? is a Software Office package intended specifically for databases, and for being Office as well as excel is the best suited to continue working with VBA. I searched quickly here and found some examples that can help you: here, here here. Good luck!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.