UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> VBA 2 Max Lotus Notes Window Not Working Right, Access 2010    
 
   
stngman
post Mar 15 2016, 03:25 PM
Post#1



Posts: 184
Joined: 13-April 06
From: Citrus Heights, CA


UA:

I copied some code back in the day for Lotus Notes and then never used it because it never worked right. The issue is if Lotus Notes Release 8.5.3 is minimized it will not maximize correctly to then bring to front.

When LN (Lotus Notes) is minimized and I use the following (rc = ShowWindow(lotusWindow, SW_SHOWMAXIMIZED) 'Makes Lotus notes visible.) to maximize the LN APP I don't get the app I get a maximized document that is completely blank with the exception of tool bars.

I need it you maximize the complete app, then move to front and then my create an email can and does work.
So here is the code with Declarations:
Any and all help with this would be awesome as not everyone has LN.
Note: code owner is posted as I don't copy code without giving the proper credit... However, at this point he may not deserve as it doesn't seem to work.


'Option Compare Database
'Option Explicit

' ################################################################################
#####

' Author: Klaus Oberdalhoff
' I used several scripts i found on the internet
' Klaus Oberdalhoff kobd@gmx.de
' Vers. 1.2 - 1. July 2003

' ################################################################################
#####

Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
Declare Function ShowWindow& Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long)
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim StrSignature As String
Const notesclass$ = "NOTES"
Private Function CreateNotesSession&()
'Const notesclass$ = "NOTES"
' "Neues Memo - Lotus Notes"
Dim lngname As Long
Const SW_SHOWMAXIMIZED = 3
Dim LNSession As Object
Dim rc&
Dim lotusWindow&
Set LNSession = CreateObject("Notes.NotesSession")
'DoEvents
DoEvents
lotusWindow = FindWindow(notesclass, vbNullString)
If lotusWindow <> 0 Then

'This line below is all my problems
rc = ShowWindow(lotusWindow, SW_SHOWMAXIMIZED) 'Makes Lotus notes visible. The SW_SHOWMAXIMIZED could also be set to 3.
'End of problem
rc = SetForegroundWindow(lotusWindow) 'moves lotus notes to the front. Access will not come back unless Access window is set to foreground.

CreateNotesSession& = True
Else
CreateNotesSession& = False
End If
End Function
Go to the top of the page
 
sirluke34
post Mar 16 2016, 11:01 AM
Post#2



Posts: 217
Joined: 29-December 11



Is it important that the application maximize and come to the front of other windows? Are you starting a mail and letting the user add text? I have some code that will send an email from Access VBA, like from a button click for example. You could comment out the Call .Send line and it should create the item and wait for the user to interact with it if that is the goal.

I have left much of the original code so you can see how I used it. There's also some commands that differ in Excel and I have also kept those. Basically, you will need to put in an email address for strMail. This can be hard-coded or pull from a variable like a DLookup from a table.

CODE
Public Sub cmdEmailFile()

Dim strFName    As String
Dim strMail     As String
Dim nSess       As Object 'NotesSession
Dim nDir        As Object 'NotesDbDirectory
Dim nDb         As Object 'NotesDatabase
Dim nDoc        As Object 'NotesDocument
Dim nAtt        As Object 'NotesRichTextItem
Dim vToList     As Variant, vCCList As Variant, vBody As Variant
Dim vbAtt       As VbMsgBoxResult
Dim sBody       As String
Dim sFilPath    As String
Dim sPwd        As String
Dim sMgrName    As String
Dim iFndSpace   As Integer
Dim MBchoice    As Integer

'****************************************************************************
***************
     ' Unlike OLE automation, one can use Early Binding while using COM
     ' To do so, replace the generic "object" by "commented" UDT
     ' Set reference to: Lotus Domino Object
'****************************************************************************
***************

'strFName = DLookup("FirstName", "tblUsers", "[uID]=" & intUID)
strFName = "User"
'strMail = DLookup("UserEmail", "tblUsers", "[uID]=" & intUID)
strMail = you@yourco.com

On Error Resume Next

     '****************************************************************************
***************
     'To create notesession using COM objects, you can do so by using.
     'either ProgID  = Lotus.NotesSession
     'or     ClsID   = {29131539-2EED-1069-BF5D-00DD011186B7}
     'Replace ProgID by the commented string below.
     '****************************************************************************
***************
    Set nSess = CreateObject("Lotus.NotesSession") 'New:{29131539-2EED-1069-BF5D-00DD011186B7}
    
     '****************************************************************************
***************
     'This part initializes the session and creates a new mail document
     '****************************************************************************
***************
    'sPwd = Application.InputBox("Type your Lotus Notes password!", Type:=2)
    sPwd = "1234"
    Call nSess.Initialize(sPwd)
    Set nDir = nSess.GetDbDirectory("")
    Set nDb = nDir.OpenMailDatabase
    Set nDoc = nDb.CreateDocument
    
     '****************************************************************************
***************
     'If you want to send it to multiple recipients then use variant array to get the names from
     'the specified range as below
     'Add / Remove Comment mark from vCCList as per your needs.
     '****************************************************************************
***************
    'vToList = Application.Transpose(Range("A1").Resize(Range("A" & Rows.Count).End(xlUp).Row).Value)
    'vCCList = Application.Transpose(Range("B1").Resize(Range("B" & Rows.Count).End(xlUp).Row).Value)
    
     vToList = strMail
     'vCCList = Range("B5")
     'sMgrName = Range("F5").Value
     'iFndSpace = InStr(1, sMgrName, " ")
     'sMgrName = Mid(sMgrName, 1, iFndSpace - 1) & ","
            
     '****************************************************************************
***************
     'If you want to send it to multiple recipients then use variant array to get the names from
     'the specified range as below
     'Add / Remove Comment mark from vCCList as per your needs.
     '****************************************************************************
***************
    With nDoc
        
        Set nAtt = .CreateRichTextItem("Body")
        Call .ReplaceItemValue("Form", "Memo")
        Call .ReplaceItemValue("Subject", "Action Notification")
        
        With nAtt
            sBody = strFName & "," & vbNewLine & vbNewLine
            sBody = sBody & vbNewLine & vbNewLine & "This is a test email."
            sBody = sBody & vbNewLine & vbNewLine & "Here is some more text with a hyperlink to a file location below."
            sBody = sBody & vbNewLine & vbNewLine & "file://C:\YourFolder\YourFile\File.xls"
            sBody = sBody & vbNewLine & vbNewLine & "Signing off..."
            '.AppendText (Range("C2").Value)
            .AppendText sBody
                
             'Decide if you want to attach a file.
            'vbAtt = MsgBox("Do you want to attach a document?", vbYesNo, "Attach Document")
            
            'Select Case vbAtt
            'Case 6
                .AddNewLine
                .AppendText ("********************************************************************")
                .AddNewLine
                sFilPath = myFile
                Call .EmbedObject(1454, "", sFilPath) '1454 = Constant for EMBED_ATTACHMENT
            'Case 7
                 'Do Nothing
                    
                    
            'End Select
                
            
        End With
        
        'Call .ReplaceItemValue("CopyTo", vCCList)
        Call .ReplaceItemValue("PostedDate", Now())
        Call .Send(False, vToList)
        
    End With

End Sub
Go to the top of the page
 
stngman
post Apr 4 2016, 03:01 PM
Post#3



Posts: 184
Joined: 13-April 06
From: Citrus Heights, CA


sirluke34,

sorry for late reply, got super side tracked on another project...

NO maximize isn't really the need or issue as much as I need LN to open on a new message to post the Addressee's, and add in subject line.

But it goes to a 'Workspace' window that is completely blank... and now I notice on the task bar that I'm disconnected so its opened up another LN seesion or something.

I have to go back and review...

Thank you for the code. I will review it and see if it has something I left out.

Sincerely,

Stngman
Go to the top of the page
 
stngman
post Apr 4 2016, 03:15 PM
Post#4



Posts: 184
Joined: 13-April 06
From: Citrus Heights, CA


sirluke34,

I found the issue.... it was the ma
Go to the top of the page
 
stngman
post Apr 4 2016, 03:42 PM
Post#5



Posts: 184
Joined: 13-April 06
From: Citrus Heights, CA


sirluke34,

Sorry internet got hung up...

But the issue was the maximize. Not only was it the issue, code was launching it early... removed code and directed code to go to LN later and now I'm golden.

Thank you for responding.... you code helped just enough for me to figure out my grey matter moment.

Sincerely,

stngman
Go to the top of the page
 
stngman
post Apr 4 2016, 04:20 PM
Post#6



Posts: 184
Joined: 13-April 06
From: Citrus Heights, CA


Anyone have any code that brings up Lotus Notes from being minimized on task bar to restore? Note Maximize isn't working when LN is minimized.

Thanks
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    17th December 2017 - 01:20 AM