Delete VBA module - vba

I was deleting an Access Object (a report) and Access crashed during the delete.
The object no longer exists in Access, but its module still shows up in VBA like a ghost.
If I click on it, I get a FILE NOT FOUND error.
If I try to compact & repair or compile the database, I get a FILE NOT FOUND error.
How can I solve this problem?

A potential option is to create a new database file, and import all of the content from the old database file. that will clear out the funky ghost stuff.

you write you tried compile already and it did not work.
Did you try decompile first though?
First of all make a backup copy (but am sure you already did that :) )
With Access and your access file closed type from the command prompt:
C:\yourOfficeInstallPath\MSACCESS.EXE /decompile
Access will start. Click File > Open and select the database you want to decompile
Open any module and click Debug > Compile
Then save your file and close.
Open again your file and compact it.
Let me know if it solved it.

Related

Dbeaver restore unsaved script

I am trying to restore an unsaved dBeaver script. I opened my DBeaver again after my system got shutdown abruptly and I can't find anything. All my SQL script are gone.
What can I do to restore or to find these script files?
In which folder are SQL scripts saved?
You can find all your project scripts in DBeaver in the "Projects" tab in the "Scripts" folder.
Or try to check this path manually: AppData\Roaming\DBeaverData\workspaceName\General(Project Name)\Scripts
(Some variables must be changed in this path)
If you installed DBeaver with snap on Linux, check
~/snap/dbeaver-ce/198/.local/share/DBeaverData/workspace6/General/Scripts
(change the number 198 or workspace6 to what you have)
Mind that the .local is a hidden folder, you need to show hidden files if you just click there.
Then check whether you find some temporary files in there.
You can find it in C:\Users\[your_user_name_enter_here]\AppData\Roaming\DBeaverData\workspace6\General\Scripts if the path yields an error, you can go on from C:\Users\[your_user_name_enter_here]\AppData\Roaming\DBeaverData. Otherwise, you can follow the same way as seen below image.
Since your scripts weren't saved on the disc, they are gone. Unfortunately, there is nothing you can do.
I have deleted a script by accident in DBeaver.
I've pressed Ctrl+Z on the left panel and the script appeared, but corrupted. So rigth click > Compare with > Local history
Then I could see previous versions. Hope this helps anyone. LOL
Steps

VBA won't compile? "Error Accessing the system Registry"

I was working on a Form and then Access crashed. When I tried to open it, I was prompted with an error which I didn't recognize how to fix right away. Something like
Form1 doesn't exist , if the invalid form name is in a macro ...
At the time, I couldn't figure it out, so I hit "Compact and Repair", closed and re-opened access a few times. Then there was another message, don't exactly remember but soemhting like "To continue, all VBA code must be deleted." I said Ok, because I have a few back up copies. But that didn't fix anything.
Then I figured out how to fix the original error. "Form1" was my default form to open on startup, so I changed it. So everything works, I copy the code back in, but obviously the code doesn't work. The error message is:
Compile Error user defined type
on the DAO.QueryDef
Then I follow MS Help and check the references, and when I click on Tools -> References, I get
Error acessing the System Registry.
So, any thoughts that include not messsing with the Registry?
Ok, so the real problem was the
Compile Error: User-Defined Type Not Defined
iDevelop was right, the file was corrupted. I had to make a new access file (they were .accdb not .mbd , but some concept), and import all objects without the code.
To make sure wasn't corrupted, I copy pasted it into Notepad first, and then into the new file. (Just as an extra precaution). And then it worked.
I am still getting the error:
Error accessing the System Registry.
when I go into Tools-> references,
but, I think it is probably related to my permissions, so maybe it is intended.

Exception trying to Start a process after copying the file

I'm getting an annoying error like:
The process cannot access the file 'C:\Program Files (x86)\AceHc\trfpt.exe' because it is being used by another process.
The error happens when I try to use Process.Start after File.Copy the same file.
Code:
File.Copy(PathFrom & "\trfpt.exe", PathTo & "\trfpt.exe", True)
Process.Start(PathTo & "\trfpt.exe")
What am I doing wrong?
Do you have a virus scanner that might be scanning the file directly after the copy and blocking it?
It might be worth trying to temporarily disable it and see if the problem goes away.
Also, depending in the size of the file, maybe the EXE file is still being copied (that is, the copy function doesn't block que program flow, your code continue and the copy process continue in background).
Download Handle from Windows Sysinternals and run it as admin from cmd to get a list of processes which hold a handle on that file:
handle.exe trfpt.exe
A wild guess - do you have a Windows Explorer window open looking at the folder 'Pathto' ?

"There is no editor available for ../Form1.vb" error?

I was happily using VB.NET, saved, and, well, there was a blackout.
Probably lucky? Well, now I open my project just fine, double click the Form1.vb and.... "There is no editor available for ../Form1.vb, make sure the application for the file type (.vb) is installed."
.......... Did something go wrong with my project? Is it dead?
Windows 7, Visual Basic 2010 Express.
What should I do?
The same thing just occurred to me but I couldn't get it fixed trying the previous answers. For some reason, one of my references Microsoft.Office.Core had a yellow exclamation point on it.
Simple Solution
Solution Explorer
Expand References
Right click on the item with "Yellow Triangle w/ "!" point"
Select "Remove"
Open the "Build" Menu at the top
Select Rebuild "filename"
Once this was done, I could open my forms correctly.
It's difficult to imagine what you're seeing. I've seen plenty of cases where the design view won't open for whatever reason, but I've never been unable to view the code for the form.
First thing to try is navigating to your project folder in Windows Explorer, right-clicking on the Form1.vb file, and trying to open it in Notepad. This is pretty much the ultimate test. If you can open it in Notepad, your work is salvageable. If not, the file is corrupted and your best bet is to start over. I suppose if you really feel that you have a lot invested, you could try various file recovery techniques, but considering it's a single form file, I seriously doubt it's worth the time or expense.
If that succeeds, and you can open the file in Notepad, select all the code and copy it to the clipboard. Now go back into Visual Studio, and add a new Form to your project. Delete everything in the new form's code file and paste the salvaged code from your original form back in. You still won't be able to open the form in the designer though, and you'll likely be missing references to all of your controls. Ignore all those squiggly underlines for now.
To fix that, you need to go back to Windows Explorer, and find a file named Form1.Designer.vb. This is the partial class that the designer saves information into; it contains declarations for all of your controls and the properties you set for those controls at design time. Just as before, right-click on this file and open it in Notepad. Select everything and copy it to the clipboard. Now go back to Visual Studio, and click on the "Show All Files" button at the top of the Solution Explorer (hover over them to read the ToolTips). You'll see a bunch of extra junk show up, but what you're primarily interested in are the drop-down arrows that just appeared to the side of every Form class. Expand the new form you added in the previous step, and find it's .Designer file. Delete everything that's in there now, and paste in the code from your salvaged form's .Designer file.
You now have an exact copy of your old form in your project. You can delete that old, corrupted form file, because you're no longer using it. You'll also probably want to change the name of the new file itself by right-clicking on it in the Solution Explorer—right now, it's named Form1 just like your old form, because it's an exact copy of that form. The code says it's name is Form1 and couldn't care less about your file name. Clean and rebuild your project, and if things go your way, everything should be back to normal.
Windows 7/ Vista:
Try right clicking the .vb file and selecting the "Previous versions" tab. When the list has loaded (if it has) select the most recent file from the list and select "Restore". Now reload your project, try doing this with all of the form files, e.g. "Form1.resx" and "Form1.designer.vb" and "Form1.vb" and then reload the project.
It implies that the file is corrupted.Replace an uncorrupted copy of that file in the corresponding directory and then try.
I had the same problem and it was from a bad reference to Excel caused by copying the project from a Win7 machine to a Win8 machine probably.
Open the solution explorer and expand the references You will see two references with the yellow exclamation mark icon beside them indicating a problem - Microsoft.Office.Core - Microsoft.Office.Interop.Excel Right click on both these icons and click remove Your form should load now, if not, save the project, close it then reopen it.
i have this problem too . when i restart Visual Studio the form create successfully and show it's designer.
I've created the Form with a different version of VS, other than 2012 (eg VS 2010, VS 2013, VS 2015; I've used VS 2015). Save the Form in the solution, open the solution with VS 2012 and include the form in the solution. It worked for me.
To fix the problem you need :
1) NotePad++
And you should follow this simple steps :
1) Close Visual Studio .
2) Go to the Backup Folder of your VS version usually in : "C:\Users(your user name)\Documents\Visual Studio (year)\Backup Files\your project or application name" .
3) Open the last Backup file of your corrupted file , usually the name format is : "Recovered-month.-day-year-time.(Your File Name).cs" with NotePad++ , and copy the source code .
4) Go to your corrupted file in the project folder and open it with NotePad++ , Edit => Select All => Past the source code and Save .
5) Go to windows start list and search for : "Visual Studio Tools" folder , open it and double click on : "Developer Command Prompt for VS(year)" .
6) Write this two codes in the Developer Command Prompt : "devenv.exe /setup" and then "devenv /resetskippkgs" .
7) Open your project .
Note : if this didn't work for you try to do the steps before in this arrangement :
1) => 2) => 3) => 4) => 7) => 1) => 5) => 6) => 7)
and your problem will be fixed .
It works 100% for me , i hope this will helps you
Try changing the security permissions on the form affected. Right click the file, go to properties then security and change the access ability to everyone.

Where does Outlook store the VBA code files?

I had a VBA project in outlook with a few email macros - but after a PC crash they are all gone and all I see is a fresh 'Project1' when I hit Alt+F11
I'm not a VBA programmer, but had a collection of handy macros for email sorting etc. I would not like to have to code them again. Anyone know where the code files should be on the filesystem so that I might rescue the code?
This page has some really good insight on where Outlook keeps all its stuff. It suggests the following:
All Outlook macros are stored in a single file named VbaProject.otm in the user's %appdata%\Microsoft\Outlook folder, which will be a hidden folder on most systems.
Now, the problem is that if you do not see them now, then you probably won't be able to restore them from that location: there is probably either an "empty" project there or no project at all, but if that folder is being backed up, you might be able to restore it.
Moving forward, you might consider exporting your macros periodically in case this happens again, either through the VBA IDE (right-click and select Export File...) or using one of the tools mentioned in the linked article (like the Office Profile Wizard).
Ok. things to try to fix this...
I assume after the problem occured you tried logging back into the same windows user account, and the same Outlook profile.
Create a new windows login to the machine in question.
Login to this account and open Outlook, this will create a new outlook profile. make note of the profile name (to find this: Control Panel > Mail applet > Show Profiles...)
Now Exit Outlook, and make sure it is not running (check for outlook.exe in task manager).
Open Windows Explorer.
Copy (don't cut) the existing VbaProject.OTM file. (if it has any other name than that, first rename it to VbaProject.OTM, then copy).
Navigate to C:\Documents and Settings\USERNAME\Application Data\Microsoft\Outlook
(or use the environment variable notation %appdata%\Microsoft\Outlook for vista/win7)
Rename the existing VbaProject.OTM to VbaProject.OTM.OLD
Paste the VbaProject.OTM from step 5 into this folder.
Reopen Outlook and test (i.e. Alt + F11).
Good luck with recovery.
If this doesn't work do you remember adding self signing certificate at all? If so have you got a copy of the cert? you can try reinstalling it into the certificate manager (certmgr.msc)
copy/install it to the Certficiates - Current User\Personal\Certificates hive.
I just found this note from Sue Mosher (outlook VBA guru):
"AFAIK, once an .otm file is corrupted, it can't be recovered. That's why I recommend that people who rely on VBA code export their modules or backup the entire file. "
All macros are embedded into an OTM file, under the following location:
C:\Users\(***Your User Name***)\AppData\Roaming\Microsoft\Outlook\VbaProject.OTM
To restore, replace this file with the older one, it should work
Ran into this same problem.
First reviewed the .otm file mentioned by #Anonymous Type and #Dave DuPlantis
Not corrupted... hmm
I checked my Ribbon in Outlook for the Developer tab. It was missing and simply re-adding it to my Ribbon fixed my problem.