Linked Excel file opens when Access front end opens- How to stop this behavior - excel

I have Ms access- frond end which is distributed to more than 50 Users and its works very well until today i come across a weird behavior.
today, I have linked one excel file in back end and use this linked table in front end a create a form using query (view only) and updated my front end. through my test I found that if I open two instance of my front end and open the newly created form than in second instance access open my the linked Excel file as readonly.
My question is, how can i avoid this behavior? I don't want my users to see this excel file by any way. is there any work around?

That's by design. An Excel workbook hosted on premise cannot be shared for writing.
One workaround is to create a copy of the workbook for each user. For instance, let your application copy the workbook from the shared location to a local subfolder of %LocalAppData%, the user's local data folder, and link to that.

Related

How to prevent user from saving changes to the master excel file?

I have a fair understanding of basic to intermediate VBA coding - here's the predicament I am having at work - I am responsible for maintaining this master excel file that consists of 35 tabs and macros and event procedures etc. - this file is used by the other team (more than 10 people) as the primary tool for carrying out their daily tasks - as the author i always keep an original copy of this file as a backup for any contingent event, and I put a copy of the file in the team folder for the team to use.
However, it sometimes happens that some of the team members would open this file in the team folder and make changes (they are told not to) as normal practice and accidentally save the changes withtout realising it - now that potentially creates an issue for the next user (good user) who would make a copy of this file and save it to their own folder and continute to work on with it (good practice) but they did not realise there has been data left in the workbook from the previous user - this kind of incident could create a disatrous consequency if it's left unnoticed.
I am trying to think up a way or series of codes that can resovle the issue - i just do not know which way to begin with - I was thinking of using SheetChange or Open (eg upon detecting any change then save as a new file in a different location) event - with that i ran into another issu- how i do ensure the subject event will not intervene other events that already exist in the workbook in the subsequential workbook?
any suggestion on structuring the code to accommedate this situation?
many thanks in advance
#VBA #event #savechange
as described in above
I would keep the master copy well hidden from them.
Then, consider putting passwords on sheets they MUST not change.
Or, consider sub-master files for the detail that each team can change and then your master file can link to those sub-files to get the latest data.
I had a project to manage that had 6 team members. Gave them each their own file and linked to their data. Also passworded the functions so they could not change or delete them.
Save the file as an Excel Macro-Enabled Template (.xltm) file.
This way, on double-clicking the file (as you would to open any other file), it creates a new file and will not automatically overwrite the old file when saving.
Instead of taking copies of the file, your users simply have to 'open' the file then later save as whatever they need to.

Power Query: Get Data from an online Excel workbook (OneDrive, SharePoint)

I've asked this before, and I think I got some comments on the question not being specific/researched enough (I'm new here!) So I'm posting again, with a bit more research. Apologies if there is still anything missing:
I need an Excel workbook to get data from another Excel workbook that lives on OneDrive. I want to share the mirror workbook with other coworkers so they can reference it.
As I have it now, on my OneDrive folder in my computer I created the mirror workbook and got data from the master workbook (also in my OneDrive folder). Lastly, I have shared the mirror workbook though OneDrive with a coworker. However, when I test opening the workbook from the coworker's computer, the workbook is still referencing the file path as if it were in my computer where I created the query and the workbook files.
As I understand it, instead of a file path, the workbooks needs a URL to reference the master workbook that lives in OneDrive (which I don't want to share).
I've tried generating different share links from the OneDrive web portal but nothing seems to access. I get access denied messages.
A bit of background, everyone has their own 365 account. And I am doing everything from the app. Not using the browser version of Excel a ay point.
I've done SharePoint before using the SharePoint folder data connector. To do this, select that connector option, paste in the site URL (e.g. https://company.sharepoint.com/sites/GroupName/), and use Microsoft account as the authentication method.
Example M query:
let
Source = SharePoint.Files("https://company.sharepoint.com/sites/GroupName/", [ApiVersion = 15]),
#"Excel File Name" = Source{[Name="Excel File Name.xlsx",#"Folder Path"="https://company.sharepoint.com/sites/GroupName/Shared Documents/General/"]}[Content],
#"Imported Excel" = Excel.Workbook(#"Excel File Name"),
#"Sheet Name_Sheet" = #"Imported Excel"{[Item="Sheet Name",Kind="Sheet"]}[Data]
in
#"Sheet Name_Sheet"

Is there a method for opening a copy of a document through VBA?

I am relatively new to VBA and I need a solution to a problem I have.
Currently I have two excel documents - one which is a form where the user enters data and this is then sent to a second document which acts as a database for this information. My issue is that when people are looking in the database data cannot be sent to the second document because it is open and there are overwrite errors.
It is my intention to have the databases location hidden away within a network drive so it cannot be found meaning the only way to access I is through a button on the first document.
Is there a way that when the open button is pressed to access the database that a copy of the document is opened instead of the actual document itself so data can still be sent?
So, you have a few options here:
a) Use an actual database. Not so much to solve this specific problem (that too) but also because making a "database" in excel is usually a terrible idea in the long run. But I know that is not always possible, and it's overkill in many situations so...
b) Have that "database" workbook set as "Shared Workbook". Shared Workbooks come with their own host of issues (namely, can't edit certain aspects like the VBA in them, conditional formatting, and others). But if it's strictly for reading and writing data, it can work. It also comes with its own version control, so that's good.
c) What you originally asked. It is quite simple really, as you said, you make a copy of the document, ideally in one of the user's local folders . You can do this using FSO (see VBA to copy a file from one directory to another)
The only issue with this last approach is that you need some way to track when the user has closed that temporary file, in order to delete it (if you absolutely don't want to leave any traces). Otherwise, you can just leave it, and overwrite that same file each time the user presses the "View Database" button.

How to modify data in an External data base connection using excel as a front-end

I have an excel front end which connects to a number of data sources. I would like changes made to the data using the front end, to update the source. How do i do this? The connections are to locally stored workbooks. They will eventually move to network stored workbooks which others can modify directly.
Your best bet is probably a connection string. Then use some SQL queries. Although I have not tried it myself. My co-worker does it all the time - update a front-end workbook then then update another workbook automatically by VBA.
Source: https://www.connectionstrings.com/excel/

Unable to determine why workbook gets marked as read only when opening another workbook via VBA

Background: I can't seem to find an answer for the blunder I've found myself in. I'm working on a dashboard of sorts for our organization that pulls data from different workbooks in different locations. Different people have different permissions within folders in our company. We're trying to prevent having to change permissions. I was also trying to make it easy as possible for employees by moving the necessary supporting files I pull from to my folder where the dashboard is housed that includes a folder with the supporting files. Since this folder has no restricted access, I added passwords to the whole workbook of each supporting file. I created workbooks in the original locations of where these supporting files used to reside with the hopes that would hopefully allow anyone with access in that folder to use this new file as a backdoor/shortcut of sorts. The goal was to keep people's files where they wanted them and allow them to click it then it takes them to my support file and enter the password for them. Which leads me to the problem...
Problem: When I open the "backdoor" file, everything runs normally and the support file opens up with read and write privileges. However when someone else opens the backdoor file, the support file opens as read only. While I don't have any code yet to determine if someone is in the file (I'll cross that road if my problem is resolvable), I've ensured nobody was in the support or backdoor file when another user attempted to use it.
Sub Workbook_Open()
'I didn't have the next statement orginally. Added it in hopes it'd resolve the issue.
'Tried to move it under the workbooks.open command, too, but to no avail.
SetAttr "M:\Report Writing\Supporting Files\TMR 2017 - Team ABC's SF.xlsm", vbNormal
Workbooks.Open "M:\Report Writing\Supporting Files\TMR 2017 - Team ABC's SF.xlsm", , False, , "XXX"
Workbooks("TMR 2017 - Team ABC's.xlsm").Close
End Sub
I also didn't originally have the "False" in the open.workbooks command but tried to add it in hopes of resolving my dilemma. Any hope is GREATLY appreciated as my whole dashboard is relying on this and we were supposed to deploy today.
It has nothing to do with the VBA code. It is the file itself. On a shared network, depending on how it was set up, when a new file is created everyone can read it, but only the creator is marked as the only one allowed to make changes. If someone Saves the file with another name you wont be able to edit it. You created the file, you can make changes to it.
There is a way to change this. Right click on the file, properties, security, Edit Button, There are some listed users in there but just find the one that says Drive\Users or Authenticated Users, or both, and edit that to provide modify access. This will allow everyone to edit the file.

Resources