How to close file explorer window using lotus script

keerthana

I'm writing a code to export the CSV using free file in lotus notes the code works fine but I'm facing an issue while closing the file explorer window. The scenario is if I don't need to export now and unknownly click export button it asks for fine name opening the file explorer window. The file explorer window it is not closing it asks for filename and its looping till i give the file name.

My code:

Sub Initialize 

    Dim ws As New NotesUIWorkspace
    Dim session As New NotesSession
    Dim source As NotesUIDocument
    Dim db As NotesDatabase
    Dim dc As NotesDocumentCollection
    Dim doc As NotesDocument
    Dim headerString As String
    Dim header As Variant
    Dim sno As Variant
    Dim vw As NotesView
    Dim flag As Boolean
    REM Get selected document
    Set db = session.CurrentDatabase
    Set dc = db.UnprocessedDocuments
    Set dc=db.Alldocuments
    Set doc = dc.GetFirstDocument
    sno=0
    Dim count As Variant
    count=0
    While Not doc Is Nothing
        filenames = ws.SaveFileDialog( _
        False,"File name",, "E:\samp", ".csv")
        If Not(IsEmpty(filenames)) Then
            REM Write Body item to file
            fileNum% = FreeFile()
            Open filenames(0) For Output As fileNum%
            headerString ="S.No,UNID,NAME,STATUS,TIME"  
            header = Split(UCase(headerString),",") 
            Print #fileNum%, headerString
            Do Until doc Is Nothing
                If (CStr(doc.Getitemvalue("Status")(0)="Accepted")) Then
                        sno=sno+1
                        d=sno+","+doc.Universalid+","+doc.Getitemvalue("Uname")(0)+","+doc.getitemvalue("Status")(0)+","+doc.Getitemvalue("Time")(0)
                        Print #fileNum%,d   
                        flag=0
                Else
                    flag=1
                End If  
                Set doc = dc.Getnextdocument(doc)
                count=count+1
            Loop    
            Else
                
        End If  
    
Wend
        If (flag="1") Then 
            MsgBox"no documents were accepted"
        Else
    MsgBox "Document exported successfully" 
    End If  
    Close fileNum%
End Sub 

Rob Mason
If Not(IsEmpty(filenames)) Then
    '<code removed for brevity>
Else
    set doc = nothing
End If
               

Put an else statement in as above, this way when you send no file name, the doc is set to nothing and the while loop exits.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to close a terminal window using Apple Script

AHK: How to store a selected file in a variable to execute an script using FileSelectFile function after selected in Window/File explorer?

VBA/ How to close Project Explorer window with a shortcut

How to close windows file upload window when using selenium

How to close specific file explorer in C#?

How to close File Explorer in `selenium webdriver`

How to edit a .bat file in the Winrar window explorer?

how to retrive directory address and file name in lotus notes script

How to download attachments from lotus notes using vb script

How to get author of a Notes document using lotus script?

close all open folders in file explorer using batch

How to set the Explorer window of a specific file as a child window of TopMost form?

How to close tab without using window open

how to trigger a function on window close using angularjs

how to close a particular window using BATCH or CMD?

How to close a popup window using Javascript

How do I close a tkinter window automatically, after using a button to export a file

How to Open and Close Internet Explorer from batch file?

How to open file from VSCode file explorer in same window

Auto save PDF file from Internet Explorer window using VBA

How can I hack the IntelliJ Idea Command-line Launcher script to open a file in an independent window and wait for close?

How to close command window after batch script completion

Batch runs python script.. how to close cmd window at end?

How to close a cmd window and open a new one to continue the script

DM script to close dialog window

File Explorer using Java - how to go about it?

How to upload file using loopback api explorer?

How to close one explorer.exe's window instead of ending the whole process

Possible to set default sort to "Type" in File Explorer using script?