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.
Related
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.
Start to get Excel catastrophic failure error
On OK opening debug windows, with auto creating each time new sheets, which is empty and strange structure
If I want something to do appears
So how to delete those sheets? or fix that error?
No background process started, file stored in xlsm and xlsb format do the same things. workbook and worksheets is not protected.
It looks like the file has been corrupted. It is unlikelly the problem can be easily reproduced from scratch.
Never the less you can script a vba macro to delete Sheets based on their names or not delete the sheets you want to keep.
sheetnametodelete= "sheetname"
With Application.Workbooks(ThisWorkbook.Name())
.Unprotect (yourpassword) ' required if protection is set
Dim wks As Worksheet
Set wks = .Sheets(sheetnametodelete)
If (Not wks Is Nothing) Then ' also check if wks belong to the defined blacklist
wks.Delete
End If
.Protect (yourpassword) ' required if protection is set
End With
Try to open the file from another computer in case your local Excel config is corrupted.
I had a similar problem (a fake workbook duplicated) in the past and decided to script a build process for my Excel vba based application.
See following links to learn more about module management.
https://www.rondebruin.nl/win/s9/win002.htm
http://www.cpearson.com/excel/vbe.aspx
you can also look at this post
Import a cls files and create a sheet
It provides code and comments from other contributors.
This is obviously not direct answer to your problem but if you intend to work on a consistent vba project I recommand to save your vba code out of your Excel file once in a while and setup a build of your Excel app.
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.
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?
I have a question on the macro events here. Below is my code. This performs the below Operations’
Private Sub SaveAsTabDelimited(ByVal sFileName As String)
With ActiveWorkbook
.SaveAs Filename:=sFileName, FileFormat:=xlText, CreateBackup:=True
End With
End Sub
Public Sub test()
SaveAsTabDelimited "C:\Users\te160772\Desktop\Toad Test\Testsanthu.txt"
ActiveWorkbook.Close savechanges:=True
End Sub
It converts the excel file into tab delimited txt file
It creates a backup copy of the excel file
I wanted this action to be performed each day inorder the excel file to upload to Oracle tables on daily basis. The reason behind converting excel spreadsheet to tab delimited txt file is to preserve the format (To prevent the removal of leading zeros while exporting it to oracle)
But now I am trying to enhance this code so that the following actions should be performed without any glitch. I have tried to do this in all the possible ways .since I am very new to the programming I was not able to do this.
The code should convert the excel file to tab delimited save on my desktop (Hope that my current piece of code is sufficient for this action)
It should create a backup copy in a folder called “Repository” (A folder in a desktop). Each change to my workbook should result a backup copy with the version history if possible(Date and Time stamp in the file name)
the biggest problem associated with my code is that upon close, three separate dialogue boxes appear - one asking me if i want to save, the other asking me if i want to keep what i have copied in the clipboard, another one is replace the existing text file saved in the folder is there a way of answering these dialogue boxes (or suppressing them) from within the macro, so i do not need to manually click on yes or no each time the macro is run?
I have attached my macro to a “shape” in excel but my priority is to run my macro upon closing of my workbook. Every time when any changes happen to my workbook and when I save the workbook, it should create a tab delimited Text files which should replace the existing Txt File without any confirmation dialogue boxes.
Please help me on this. This is badly require for me
With a million thanks
The code should convert the excel file to tab delimited save on my desktop (Hope that my current piece of code is sufficient for this action)
Yes, either you can hardcode the path to the desktop or use this code to get the path to the desktop automatically
Sub GetDesktopPath()
Dim oWS As Object
Dim DskTopPath As String
Set oWS = CreateObject("WScript.Shell")
DskTopPath = oWS.SpecialFolders("Desktop")
Debug.Print DskTopPath
Set oWS = Nothing
End Sub
It should create a backup copy in a folder called “Repository” (A folder in a desktop). Each change to my workbook should result a backup copy with the version history if possible(Date and Time stamp in the file name)
You can use the Workbook_BeforeSave event to create a copy of the existing workbook.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
End Sub
You may want to explore ThisWorkbook.SaveCopyAs See Excel Help for more info.
the biggest problem associated with my code is that upon close, three separate dialogue boxes appear - one asking me if i want to save, the other asking me if i want to keep what i have copied in the clipboard, another one is replace the existing text file saved in the folder is there a way of answering these dialogue boxes (or suppressing them) from within the macro, so i do not need to manually click on yes or no each time the macro is run?
You can get rid of these alerts by simply sandwiching your code between
Application.DisplayAlerts = False
'~~> Your Code
Application.DisplayAlerts = True
If you are using clipboard a lot, then you might also want to clear it by using
Application.CutCopyMode = False
I have attached my macro to a “shape” in excel but my priority is to run my macro upon closing of my workbook. Every time when any changes happen to my workbook and when I save the workbook, it should create a tab delimited Text files which should replace the existing Txt File without any confirmation dialogue boxes.
You can use the Workbook_BeforeClose event to run your relevant code
Private Sub Workbook_BeforeClose(Cancel As Boolean)
End Sub
Regarding the alert, I have already explained that in the previous section.
Hope this sets you in the right path.