PDA

View Full Version : Solved: "Out of memory" error while renaming module



mvidas
10-03-2005, 08:37 AM
Hi Everyone,

Strange problem. I start excel, go to VBA, click on a Module of an add-in of mine in the project window, type a new name for the module in the Properties window, and when I press enter I get a simple error msgbox titled "Microsoft Visual Basic", with contents of "Out of memory", and OK and Help buttons.

When I click help, I get the help page for "Out of memory (Error 7)" I looked in that help page and cannot figure out why I would get this error.

The code in the module, though it does contain a user defined type and 2 API calls, isn't much:Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) _
As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Public Function GetDirectory(Optional Msg) As String
Dim bInfo As BROWSEINFO, Path As String, r As Long, X As Long, pos As Integer
bInfo.pidlRoot = 0&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Select a folder."
Else
bInfo.lpszTitle = Msg
End If
bInfo.ulFlags = &H1
X = SHBrowseForFolder(bInfo)
Path = Space$(512)
r = SHGetPathFromIDList(ByVal X, ByVal Path)
If r Then
pos = InStr(Path, Chr$(0)): GetDirectory = Left(Path, pos - 1)
End If
End FunctionAny ideas? As I said, the code is in the add-in, and the file is saving fine otherwise. But as soon as I try and change the name, I get the error and the module reverts back to "Module1".

For testing, I just added a brand new blank module, "Module2". Nothing in it at all. I tried changing the name, same error. I can rename modules in any other workbook/addin.

Also, I uninstalled the other add-in I have, uninstalled the analysis toolpaks, and even closed personal.xls (leaving this 9 module add-in the only thing remaining in the project window--none of the other modules have long code in them and none contain any public variables or API calls).

I had this problem a few months ago, so I had split my add-in into two add-ins. Now I'm reviewing all my code, removed most of the modules I had in them (once I can write a routine from memory I remove it from my addin), and am trying to consolidate my addins back together (from 29 modules in the 2 files to 9 in 1 file).

I'm at my wit's end, about to go get lunch to get away from my PC, but I figured I'd ask while I was thinking about it.

Thanks!
Matt

Zack Barresse
10-03-2005, 08:43 AM
Just curious, does it help if you comment out this suspicious code and then try to rename it? This is quite odd indeed Matt...

mvidas
10-03-2005, 09:04 AM
Nope, I just tried even removing everything in it, adding a completely new module, and it still gets it. I'm guessing the workbook is just somehow corrupted.
I'm attaching a renamed version of it, with nothing in it, see if you get the same issue. If you do, I'm just going to write it off as being corrupted, and just use a new addin for it

Well I can't even do that, it says the limit for .zip attachments is 244.1k and mine is 265k (makes sense it would be corrupted for a completely blank addin to be 923k unzipped).

So, I'm just going to mark this solved :) Stupid corruption!

mvidas
10-03-2005, 09:16 AM
I loaded my backup version of the 2 files (from sept 1), and somewhere along the way I lost a module. Oh well, couldnt have been that important if I can't remember what it was :)