PDA

View Full Version : Solved: Search for Missing Module/Code?



YellowLabPro
07-24-2007, 07:35 AM
I am looking for some code/program that will locate a Sub via a keyword search on my entire system. I have closed/lost or deleted a particular Sub I would like not to have to re-create....
I have looked through the KBase and did a keyword search "Find Module" w/out any results. I know Johnske has some code that will store Modules but not sure if this will handle satisfy my needs, but I cannot remember his KBase article to look for it.

Thanks,

YLP

unmarkedhelicopter
07-24-2007, 09:13 AM
As long as your project is not protected then a standard file search would fit the bill
Start > Search > All Files And Folders > "A Word Or Phrase In The File" (YOUR KEYWORD)

Don't forget you can specify only .xls files
Only search All Drives if you think it could be in any of them
Remember to add network drives you need to search also
Keep a screen print of ALL likely candidate search returns

YellowLabPro
07-24-2007, 03:04 PM
Hello Helli-
Sorry I could not get that to work. I have tried this previously, but was unsuccessful.
My approach- I have a Sub named Dec2Frac:
Sub Dec2Frac ()
I did a Windows search on the file *.xls and in the box- "a word or phrase in the file" I entered dec2frac.
The search yielded no results.

Bob Phillips
07-24-2007, 03:46 PM
That should work Doug. I just tried it on my machine, and it worked fine. Didn't even seem to be case-sensitive.

Tommy
07-24-2007, 04:12 PM
Hi YellowLabPro,

The below function will take a number in decimals of an inch, return a string in the format "12'-3 3/16", if iInches is True then "147 3/16". None of the Variables are dimensioned as they should be, this is something that I butchered in a hurry (I don't know why I was in a hurry:rotlaugh:). If you can't find yours we might be able to modify this if you would like.

Public Function GenFraction$(iAnum, Optional iInches = False)
mFRC = Split( _
" 1/16, 1/8, 3/16, 1/4, 5/16, 3/8, 7/16, 1/2, 9/16, 5/8, 11/16, 3/4, 13/16, 7/8, 15/16", ",")
mFt = "'-"
mBNUM = iAnum / 12
mINUM = Int(Round(mBNUM, 4))
mCNUM = mBNUM - mINUM
mCNUM = Round(mCNUM, 6) * 12
mMyInch = Int(mCNUM)
mFRAC = mCNUM - mMyInch
mFRAC = Round(mFRAC, 6)
mIFRAC = CInt((Round(mFRAC, 6) * 16))
If mIFRAC >= 16 Then
mMyInch = mMyInch + 1
mIFRAC = mIFRAC - 16
If mMyInch >= 12 Then
mMyInch = mMyInch - 12
mINUM = mINUM + 1
End If
Else
If mIFRAC > 0 Then
mIFR = mFRC(mIFRAC - 1)
End If
End If
If mINUM > 0 Then
mAFRAC = CStr(mINUM) & mFt
ElseIf mMyInch > 9 Then
mAFRAC = "0" & mFt
End If
If mMyInch > 0 Then
mAFRAC = mAFRAC & CStr(mMyInch)
ElseIf mMyInch = 0 And Not IsEmpty(mAFRAC) Then
mAFRAC = mAFRAC & CStr(mMyInch)
ElseIf mMyInch = 0 And mINUM > 0 Then
mAFRAC = mAFRAC & CStr(mMyInch)
End If
If mIFRAC > 0 Then mAFRAC = mAFRAC & mFRC(mIFRAC - 1)
If Not iInches Then
GenFraction = IIf(IsEmpty(mAFRAC), "0", Trim$(mAFRAC))
Else
GenFraction = CStr(Int(iAnum)) & mIFR
End If
End Function

YellowLabPro
07-24-2007, 04:52 PM
Tommy,
Did you mean to post this here or in my other thread: For-Next Loop?
http://www.vbaexpress.com/forum/showthread.php?p=107805#post107805

Tommy
07-24-2007, 05:00 PM
Ummm no to the other thread.

I had the code to convert from decimals of and inch to a fraction string LOL since I'm not being short sighted (hopefully). How would you like the fraction to appear? (I know this may be obviouse, but I am still thinking feet LOL)

YellowLabPro
07-24-2007, 08:11 PM
That should work Doug. I just tried it on my machine, and it worked fine. Didn't even seem to be case-sensitive.

Hmmmm- I tried it several times and no success.
I tried it w/ specific text and modules I know exist, even while they were open, but no results were found.
:dunno :(

unmarkedhelicopter
07-25-2007, 12:39 AM
Tommy, you are STILL on the wrong thread.

YLP, what does the Pro signify ?
What OS are you running ?
What access rights do you have as a user when running this ?
Try putting a simple .xls in say your C:\ and search for a word in the code base from there if that works then you have a different problem. Have you tried searching for something you "KNOW" is in a particular file & location ?

YellowLabPro
07-25-2007, 03:47 AM
Heli-
Pro is shortened project- my nickname for "Maggie" my Yellow Lab. When registering it did not allow me to use the full name, though I see you have been able to convince the Name "Gods" from above differently.... must be that flying higher in your stealth copter.... :-)

I am running XP
Administrator Rights
Show Hidden Folders and Files is enabled
If there are more settings to access rights, I am not familiar w/ these
I have not put a .xls, but rather a *.xls and searched for the following strings; dec2frac, sub dec2frac, Item In Array; in C:, C:D:H:, and MyComputer as the location to search.
Could there be a setting I am missing?

Regards,

unmarkedhelicopter
07-25-2007, 11:56 AM
As I suggested put something you KNOW is there in C:\ and if it can't find that then you have BIG problems, get back to us.

YellowLabPro
07-25-2007, 04:59 PM
Heli,
What file type does Windows find when searching for a Sub term, an regular Excel file, or something different?

Bob Phillips
07-26-2007, 12:29 AM
It is looking in a regular xls file, prior to 2007.

unmarkedhelicopter
07-26-2007, 01:39 AM
Heli,
What file type does Windows find when searching for a Sub term, an regular Excel file, or something different?

What ?

I used this technique in February to find a piece of code I written to perform mathematical operations on cells depending on their formatting so I know it worked then. I have just repeated said technique in a particular folder of a particular drive with a particular .xls file with a particular subroutine placed in it and though it will find it if you place the search word in a cell it won't if you put it in a module.
Is this another microsoft security enhancement ? :steamed: :po: :mad2:

YellowLabPro
07-26-2007, 04:07 AM
Heli,
The Good & The Bad:
The Good first: glad you found the same results I did, I like most have a VBA addiction now, but I not like everyone else struggle with it still..., losing my hair from learning this is one thing, but pulling it out HURTS!
The Bad: That is still what I had found, that it does not return a search of entered value in a module. Now Xld is still reporting that this works for him- we need to grill him to see what special super powered software he has and wrestle him for it- though he will probably put a respectable fight...:rotlaugh:
I am going to run this again- If Xld = True, Then True....

I will post back. If we enivitably find this not to be true then we need to invent a method for searching for Subs.

YellowLabPro
07-26-2007, 04:35 AM
Tommy,
I finally figured out what you were doing.... The module I was searching for had nothing to do w/ feet/inches nor sizing, I just happened to post two threads close in time to one another and you must have summized I was looking for this...
Me and Heli were completely confused....:rotlaugh:
[qoute]think you meant to post this to my other thread:
http://www.vbaexpress.com/forum/showthread.php?p=107805#post107805[/quote]
Though this did not address a current need it is something potentially very useful and powerful. I am going to save this for future reference/use as I will be working on another situation w/ ft and in.

Thank you for whipping this out. (I have to get back to your other posts to work on those- thanks for taking the time to help!

Doug


Hi YellowLabPro,

The below function will take a number in decimals of an inch, return a string in the format "12'-3 3/16", if iInches is True then "147 3/16". None of the Variables are dimensioned as they should be, this is something that I butchered in a hurry (I don't know why I was in a hurry:rotlaugh:). If you can't find yours we might be able to modify this if you would like.

Public Function GenFraction$(iAnum, Optional iInches = False)
mFRC = Split( _
" 1/16, 1/8, 3/16, 1/4, 5/16, 3/8, 7/16, 1/2, 9/16, 5/8, 11/16, 3/4, 13/16, 7/8, 15/16", ",")
mFt = "'-"
mBNUM = iAnum / 12
mINUM = Int(Round(mBNUM, 4))
mCNUM = mBNUM - mINUM
mCNUM = Round(mCNUM, 6) * 12

unmarkedhelicopter
07-26-2007, 06:40 AM
He probably doesn't have any super powered software, he was just probably more descerning when it came to which superfluous updates he chose from microsoft. I'll try this using Win98 and Linux and report back.

YellowLabPro
07-26-2007, 06:45 AM
Ok... thanks.
I did try searching specifically on a value in a Sub.
I used "Set Wsv"
Which is specific to a Sub and not in an Excel file cell. I placed this file on my desktop and confined my search to this location to reduce the search time. NO GO! Did not find.
So Bob... let us know what magic dust you are using...

Tommy
07-26-2007, 12:03 PM
I think the modules and such that are stored in an .xls file are encrypted so the search functions will not work, they look for ASCII text. grep (in Linux) is looking for ASCII also so it wouldn't work either AFAIK even if you imported it into OpenOffice/StarOffice.... The only way is what xld is thinking (I'm assuming here so don't kill me LOL) is if the modules etc, were exported to an external file.

Bob Phillips
07-26-2007, 12:08 PM
Here is another post that I did that didn't make it.

I think your problem is in looking for keywords, like Set. I believe that VBA tokenizes keywords (I would have to check to be sure, but I think that is so), so you won't find Set Wfsv, it will be stored as <token> Wfsv.

Try doing a search for a procedure name and see if that works.

YellowLabPro
07-26-2007, 01:23 PM
xld-
Sorry no luck on that front. I have a workbook- Book1.xls on my desktop w/ a module in named Module9 and the Procedure name is testk.
I searched on the file name of .xls and testk as the string for the word or phrase in and limited it to a Desktop search....
No luck.
I think I have exhausted all possible variations to find a Sub via Windows search.
Lets see what Heli turns up. But you are able to do it so.....

unmarkedhelicopter
07-27-2007, 03:56 AM
I have not attempted to look for "Sub NCommon" or "Function NCommon" but just the names i.e. "NCommon" when I have opened the file in a hex editor I can see the word "NCommon" so Windows should find it.
As I said I've used this before sucessfully and Bob says it works for him.

unmarkedhelicopter
07-27-2007, 04:04 AM
I've just tried it on Linux and though I had to check "look in binary files" (it didn't work without) it did work !
Now Windows will look in Excel file to look for data contained in cells but in some time since February my Win XP will not look in the binary portion of the Excel file.
Yella, you can search for stuff under Linux, have still yet to test Win 98.

YellowLabPro
07-27-2007, 04:09 AM
Yella, you can search for stuff under Linux
I do not use/have not used Linux. Will I have to get a copy of Linux, which I am assuming will be the case, to get this to work?
And w/ Linux being an OS... I am assuming I will have to install another OS on my system? Just covering points here...

unmarkedhelicopter
07-27-2007, 05:22 AM
If you don't have it don't bother, same is true for win98 if you don't already have mutiple operating systems installed then installing them just so you can search is a bit of overkill.
How about something like ZTree ?

Bob Phillips
07-27-2007, 06:48 AM
http://www.knoppix.org/

YellowLabPro
07-27-2007, 07:57 AM
Heli,
I agree...
I downloaded PowerGREP and playing w/ this... it may be a successful option but at $149... too much for me

unmarkedhelicopter
07-27-2007, 10:05 AM
What was wrong with ZTree ? http://www.ztree.com/html/ztreewin.htm?gclid=CM-klrGbyI0CFQTUlAodVGGi6w it is VERY remenicent of the old XTree which any serious DOS power user would not be without but I'm not sure it'll fit the bill.

Instead Try this :- http://www.replsoft.com/index.html it's free ! (I think)
Edit : Sorry you can use it 15 times then you have to register it (not sure what that means, whether cash is involved ???)

YellowLabPro
07-27-2007, 10:09 AM
I will give it a go.... I had been looking for an answer once you directed me to searching on Binary and that was a free trial download.
I will have to research ZTree, don't know that one...
And then Bob gave us Knoppix.... so a few more options to explore.

I will have a look at the links you posted... thanks

All this seems so unnecessary- Man on the Moon vs. The Common Cold...

cheers

unmarkedhelicopter
07-27-2007, 10:15 AM
Knoppix is a Linux distro ...
UFU definately finds words in binary files, just tried it :)

YellowLabPro
07-27-2007, 05:59 PM
Heli,
Have not had the opportunity to look up the links you posted... still sorting out some code issues, but what is UFU?

unmarkedhelicopter
07-28-2007, 01:09 AM
They call it "Useful File Utilities"

Bob Phillips
07-28-2007, 02:03 AM
Knoppix is a Linux distro ...

I wouldn't call it a distro, more like a bootable Linux on a stick (CD/DVD). You can boot into Linux direct from the stick, no need to fully install, saved me many times.

unmarkedhelicopter
07-28-2007, 05:15 AM
A one of the 'live CD' things, good point. I've always gone for a full install, never had aproblem, just lucky I guess.

YellowLabPro
09-20-2007, 04:38 PM
UMH-
The UFU worked brilliantly. I had totally forgotten about it until today. I had to find a Sub and it was literally lost. Downloaded the program, loaded it up and it found it right away....

Muchas Gracias!!!!!!!!!