VBA ProjectPassword

zplugger

Active Member
Joined
Apr 19, 2009
Messages
339
At the end of the road on this problem,need any suggestion I can get. This is posted on another too.
VBA ProjectPassword

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.
Thanks for looking Z


Code:
Private Sub CommandButton1_Click()
Dim ol As Object
    Dim ns As Object
    Dim fldr As Object
    Set ol = CreateObject("Outlook.Application")
    Set ns = ol.GetNamespace("MAPI")
    Set fldr = ns.GetDefaultFolder(6) 'inbox
    fldr.Display
    ol.ActiveWindow.Activate 


End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Got a fix,
VBA Project Password

Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal ClassName As String, ByVal Title As String) As Long 
Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long 
 
Sub CB() 
     
     
    Dim ol As Object 
    Dim ns As Object 
    Dim fldr As Object 
     
    Set ol = CreateObject("Outlook.Application") 
    Set ns = ol.GetNamespace("MAPI") 
    Set fldr = ns.GetDefaultFolder(6) 'inbox
    fldr.Display 
     
    BringWindowToTop FindWindow("rctrl_renwnd32", vbNullString) 
     
End Su
b</code>
 
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,608
Members
449,174
Latest member
ExcelfromGermany

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top