PDA

View Full Version : Solved: Run Once Then Delete Code



steve.t
11-20-2007, 11:21 PM
Hi experts,

I tried running the workbook at http://vbaexpress.com/kb/getarticle.php?kb_id=511 and it didn't do what it was supposed to, i.e. to delete the module.

Is the code absolutely correct, or am I doing something horribly wrong, or what?

Cheers,
Steve

Charlize
11-21-2007, 02:28 AM
Working fine for me.

steve.t
11-21-2007, 05:12 AM
Dear Charlize,

I followed the "test the code" instructions exactly. Absolutely no success, even after several atempts, just to make sure I was doing everything correctly.

Another issue: in the "How to use" instruction, I don't understand steps 4 and 5,

quote

4. Select the thisWorkbook module
5. Copy and paste the ThisWorkbook module code into this Module

unquote

What is the "ThisWorkbook module", and where do I find it.

Although I am a Newbie at VBA, I pick things up very easily, and have already created several projects;

but I am totally confused with this one. Any other suggestions?

Cheers,
Steve

rory
11-21-2007, 06:34 AM
In the Project Explorer window (usually top left window) in the VBEditor, for each project you will see a folder called Microsoft Excel Objects. Within this you will see each sheet and a ThisWorkbook object. Double-click the ThisWorkbook object to see its module.

lucas
11-21-2007, 08:46 AM
Click here (http://slucas.virtualave.net/Wink/ThisWorkbookModule.htm) for a short flash presentation that will show you how to find the thisworkbook module.

steve.t
11-21-2007, 04:24 PM
Thanks Rory and Steve,

I had no problem identifying the various elements of the editor window.

As I said, I followed the "Test the code" instructions to the letter. I even set Macro Security to Low. I looked at the references, and Microsoft Visual Basic for Applications Extensibility 5.3 is checked. No problem there.

At Step 8, the "RunOnceModule" was still there, and regardles of how many times I opened and saved and closed the workbook, no change.

To clarify, I'm running Microsoft Excel 2002 SP3 on XP Professional.

Any suggestions?

Cheers,
Steve

MWE
11-21-2007, 04:56 PM
I downloaded the workbook and it does not work (delete the module) for me either (xl2K, WinXP)

Bob Phillips
11-21-2007, 04:59 PM
Did you remove the apostrophe at the start of the code line as advised in the comment?

tpoynton
11-21-2007, 05:04 PM
test workbook worked for me (Excel 2003, WinXP). it didnt the first time, because I didnt read the instructions :)

steve.t
11-21-2007, 07:03 PM
Hi VBAExpress users, problem solved - security issue.

To be able to run the code as intended, you must go to Tools>Macro>Security - Trusted Sources and check Trust access to Visual Basic Project before running the code/workbook. Once this is done, it works perfectly.

Cheers,
:beerchug:
Steve T