VBA Project Password

  • At the end of the road on this problem,need any suggestion I can get. This is posted on another too.
    http://www.excelforum.com/exce…-vba-projectpassword.html
    http://www.mrexcel.com/forum/e…ions-projectpassword.html



    If I put this code on commandbutton it will open outlook in front of workbook,if I put a VBA Project password on it and close and save.When I reopen the workbook and run the code outlook opens behind the workbook? What does the password have to do with this? Looking for suggestions for a fix. Got to ask all the experts on this,two day of trying stuff with no luck
    Thanks for looking Z



  • Re: VBA Project Password


    Interesting little glitch - you don't mention the version (always nice to know for sillies like this) but also evident in Office 2010...


    Try this...


    I would have used the VBA AppActivate command in preference but I couldn't find the object/property that held the Window caption needed for AppActivate.


    Normally the FindWindow API function also needs the caption, but as there can only be 1 instance of Outlook the class name (rctrl_renwnd32) on its own is good enough.

  • Re: VBA Project Password


    I can not duplicate your problem. Maybe you can make a simple one and attach it? Tell us the password if you do in case we need to do something with the code.


    Be sure to use Form command button control rather than ActiveX.

  • Re: VBA Project Password


    Hi Kenneth,


    I copied the OPs code and pasted it into a module in a new workbook. Called it from a Forms button on a sheet, saved the workbook and quit Excel. Restarted, opened the workbook, clicked the button and Outlook ended up as the foreground app.


    Added a password to the project, saved & quit. Restarted, loaded and clicked the button - Excel was the foreground app. That was my understand of the problem as stated above, and for once I could replicate it! :)
    .

  • Re: VBA Project Password


    Win 8.1/64 Office 2010/32


    Running your code on this machine has Excel as the foreground Window when the code terminates... I would attach my test workbook but it seems pointless.


    Edit - Odds on (caveat below) the OP is running Win 8/64.
    It seems to be Windows version specific. Issue not evident on Win XP/Office 2003 or 2007, Win 7/2007 or 2010 (All 32 bit) - However these are all running on virtual machines which are atypical installations.

  • Re: VBA Project Password


    Didn't I just mention 64 bit...? Oh, I got the version wrong :)


    Whatever the issue is then, it seems to be specific to 64 bit Windows installations - now wondering if it only affects 32 bit versions of Office running on 64 bit Windows.


    Might even tempt me to drag out a 64 bit version of XP and test on that...

  • Re: VBA Project Password


    Guess this is just one time I can't help since it works for me.


    The API method that cytop used was one that I used for other focus problems in the past.
    Maybe...

    Code
    'fldr.Display
        'ol.ActiveWindow.Activate
        Application.ActivateMicrosoftApp xlMicrosoftMail

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!