Excel 2016 sharepoint file still opens as readonly - excel

Since updating to Office 2016 I can't get excel to open a sharepoint file as editable, despite declaring it to do so.
Workbooks.Open ThisWorkbook.Sheets("Filelist").Cells(i, 2), _
UpdateLinks:=False, ReadOnly:=False, Local:=True, Editable:=True
The file opens without issues, but I have to run a break on the next line to stop the macro and manually select EDIT, before allowing the code to proceed.
Whilst this is an obvious work around, I am looping through about 40 files, and have to do this manually in each open instance.

Ok so I found a solution to this LockServerFile is the equivalent of hitting the Edit Workbook button.
When opening with VBA you can follow the open command with:
Workbooks.Open ThisWorkbook.Sheets("Filelist").Cells(i, 2)
ActiveWorkbook.LockServerFile
Solved my problem for now if anyone comes across a similar issue.

ActiveWorkbook.LockServerFile
The above code will lock that workbook for editing.
You can edit the workbook and you can save it.
But when you try to open the workbook again by manually, the changes you had done will not reflect in that sheet.

Related

How does Excel know that a file "was not recalculated before it was last saved". Can I trick Excel into thinking the opposite?

When linking workbooks in Excel, I often get an error like:
Links to xxxx.xlsx were not updated because xxxx.xlsx was not recalculated before it was last saved
This error pops up once for every linked value, which means in my case about 100 alerts I need to press OK for. Mysteriously, this alert comes even if xxxx.xlsx contains no formulas and hence no recalculation at all: it's completely full of values only.
So how does Excel know that a file has not been recalculated before saving? Is it looking at a particular xml value inside the ZIP file (xlsx) which I could tamper with? Is it looking at open date vs modified date that I could circumvent with the touch linux command? I'd like a solution Using the command line ubuntu if possible (I run windows WSL), so that I can use a script.
And what's more, xxxx.xlsx is really big, which over network (thanks COVID) at home is slow to open / recalc / save. So I really don't want to ever open this file in Excel.
Any ideas?
You could try adding this macro to your PERSONAL.XLSB file and then running it. It will ask you to select a file and then open it without allowing links to update.
Sub OpenWithoutUpdatingLinks()
Dim strFileName As String
strFileName = Application.GetOpenFilename
If strFileName <> "" Then Workbooks.Open FileName:=strFileName, UpdateLinks:=False
End Sub
This will allow you to open the file you're working on without getting the message about updating links.
However, if you actually need the links to update or need to create more links, then you need the linked file to be recalculated.
Let us know if you need instructions on adding a macro to your personal file and running it.

Activating Macro view button sends excel in non-responding mode

In Excel 2013: macro was working fine until today. Now, I can open the "Personal.xlsb" file, but I cannot use the Macro view button anymore, all I get is Excel in unresponding mode; and then, only way is to stop Excel entirely. When I go in design mode, I cannot access the macro registry at all (trying to do so results in the same unresponding state). I rebooted the PC entirely, did not help.
Pb seems specific to one specific "Personal.xlsb" file (I replaced the incriminated file with another "Personal" file in the XSTART folder and Excel macros worked just fine with a different .xlsb file). So I am suspecting a file corruption pb. If that is the case, is it possible to recover the original macros, or at least crack the macro file open and get a copy of the original coding?
You can try to get back your code if you manage to open the workbook from a macro in another workbook. Give this a shot:
create a folder where you will get the recovered code modules. Let's say "C:\myRecoveredCode". Put in a copy of your corrupt file "Personal.xlsb"
In Excel Options, Trust Center Settings, Check Trust Access to the VBA project object module
create a fresh workbook, copy/paste and run the following macro:
Sub TryRecovery()
myFolder = "C:\myRecoveredCode\"
Set wb = CreateObject(myFolder & "Personal.xlsb")
For Each comp In wb.VBProject.VBComponents
comp.Export myFolder & comp.Name
Next
wb.Close False
End Sub
If all goes well, you will have files a set of files that you can edit, or import to another workbook.

exec a xlam everytime I open an excel file

I have the following peace of code to exec a xlam file when I open the excel file:
Sub Auto_Open()
Application.OnTime Now + TimeValue("00:00:05"), "readCsv"
End Sub
Sub readCsv()
....
End Sub
I add it as Add-ins so every file I open has the xlam file on it. If there is no other excel file opened, it works perfectly but after that without closing the excel file I open a second one it does nothing. I need to exec the code even if there is another excel file opened. Is that possible?
I also try to do it writing the code in ThisWorkbook but the result is the same, If there is another excel file opened it does nothing.
To use your macro in any of the worksheet opened (irrespective of name) you can only possible do it by using a personal workbook Here is the Link
If the above doesnt suits you can prepare Add-ins and install it for users (Google for it if this is the case)
EDIT:
How to get add in in all opened files....
Goto File - Option - Quick Access Toolboar - From the dropdown "Choose Command from" - select Macros then select add-in macro - Add it, Below there would be a modify button Select the icon you like from it - OK
Now you will be able to see the icon with the addin function linked on top of the excel - click it for functioning, it will remain there forever ( if missed you can reapply the settings)....
The procedure are for 2010, for 2007 it should be similar....for 2003 there is a different way to achieve it...
Copy the .xlam to C:\Users[user]\AppData\Roaming\Microsoft\Excel\XLSTART. It will load every time you open Excel.

Excel Workbook open macro reopens closed workbook

I do the following as a macro
Open a list of files
copy some values
Close them
After that when I exit and reopen the file that contains the macro, it also opens the files which I previously opened. even those I had used the app.workbook.close
I'm unable to find the problem out.
Where is the macro located? In a normal module?
At the end, seeing as how you've already pointed the variable at it, you may as well say
currentWB.close False
Then to close
Set currentWB = Nothing
Are there some links between the file that has the macro and the files it creates?

Creating a self-deleting macro in Excel 2007

I'm trying to create a Macro in Excel 2007 that will delete itself when it finishes running and close Excel. The reason I want to do this is that I am going to be sending the Workbook out to other people, and I don't want them to see security warnings about the Macros. Several versions of this Workbook will be generated, so this I don't want to manually run and remove the Macro for each one.
I've tried the following code. It runs without error, but does not actually delete the Macro. If I remove the line "ActiveWorkbook.Close SaveChanges:=True" the Macro is deleted, but this prompts the user to save the Workbook as Excel closes. Is there any way to do this without User interaction?
Dim ActiveComponent
Set ActiveComponent = ActiveWorkbook.VBProject.VBComponents("ModuleName")
ActiveWorkbook.VBProject.VBComponents.Remove (ActiveComponent)
ActiveWorkbook.Save
Application.Quit
ActiveWorkbook.Close SaveChanges:=True
Why not just move your macros to another workbook and have them operate on the workbook(s) you're sending out?

Resources