excel.exe still remains in task manager after using vbs to close and quit

Author Message
gadflyyy

  • Total Posts : 5
  • Scores: 0
  • Reward points : 0
  • Joined: 11/23/2011
  • Status: offline
excel.exe still remains in task manager after using vbs to close and quit Wednesday, November 23, 2011 3:30 PM (permalink)
0
Hi,
when I use vbscript to import table of excel format  to powerdesigner pdm, a problem confused me for a long time.
after the program ran completely, the excel.exe process was still  in the task manager, which cannot be closed itself.
 
the code is as follows,
 
dim rwIndex   
dim tableName
dim colname
dim table
dim col
Dim mdl ' the current model
Dim xlApp 'As Excel.Application
Dim xlBook
Dim xlSheet Set mdl = ActiveModel
If (mdl Is Nothing) Then
   MsgBox "There is no Active Model"
End If set table = mdl.Tables.CreateNew table.Name = "table_name"    table.Code = "DIM_CURRIER"  Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = false
Set xlBook = xlApp.Workbooks.Open("E:\xfm\gsm.xlsx")    
set xlSheet =  xlApp.Workbooks(1).Worksheets(1)  
xlSheet.Activate   For rwIndex = 3 To 6      set col = table.Columns.CreateNew       col.Name = xlSheet.Cells(rwIndex,5).Value       
  col.Code = xlSheet.Cells(rwIndex, 1).Value  
  col.DataType = xlSheet.Cells(rwIndex, 2).Value 
  col.Comment = xlSheet.Cells(rwIndex, 5).Value     
Next  ' Close Excel and spreadsheet. 
  Set xlSheet = Nothing       
        If Not xlBook Is Nothing Then
            xlBook.Close
            Set xlBook = Nothing
        End If
        
        If Not xlApp Is Nothing Then
            xlApp.Quit
            Set xlApp = Nothing
        End if
   msgbox "close the excel process!" 

 
Any suggestion will be appreciated,
thank you in advance!
 
Felix
 
#1
    fairgame

    • Total Posts : 2
    • Scores: 0
    • Reward points : 0
    • Joined: 11/23/2011
    • Status: offline
    Re:excel.exe still remains in task manager after using vbs to close and quit Wednesday, November 23, 2011 7:54 PM (permalink)
    0
    first use
    xlApp.Quit
    and then set app, sheet and book to nothing.
     
    #2
      srinu_001241

      • Total Posts : 16
      • Scores: 0
      • Reward points : 0
      • Joined: 11/14/2011
      • Status: offline
      Re:excel.exe still remains in task manager after using vbs to close and quit Wednesday, November 23, 2011 8:30 PM (permalink)
      0
      Before Set xlSheet = Nothing line add
      xlSheet.close
      Thanks
       
       
       
      #3
        59cobalt

        • Total Posts : 981
        • Scores: 91
        • Reward points : 0
        • Joined: 7/17/2011
        • Status: offline
        Re:excel.exe still remains in task manager after using vbs to close and quit Thursday, November 24, 2011 7:48 AM (permalink)
        5
        gadflyyy
        when I use vbscript to import table of excel format  to powerdesigner pdm, a problem confused me for a long time.
        after the program ran completely, the excel.exe process was still  in the task manager, which cannot be closed itself.
        [...]
        If Not xlBook Is Nothing Then
         xlBook.Close
         Set xlBook = Nothing
        End If
        
        You modify xlBook, but then you try to close it without saving. Either save the workbook before closing, or set xlBook.Saved = True if you want to discard your changes.

        fairgame
        first use
        xlApp.Quit
        and then set app, sheet and book to nothing.
        There is nothing wrong with the order of his statements.

        srinu_001241
        Before Set xlSheet = Nothing line add
        xlSheet.close
        You cannot close a worksheet, so this would just raise an error 438.
         
        #4
          srinu_001241

          • Total Posts : 16
          • Scores: 0
          • Reward points : 0
          • Joined: 11/14/2011
          • Status: offline
          Re:excel.exe still remains in task manager after using vbs to close and quit Thursday, November 24, 2011 8:41 PM (permalink)
          0
          Ok.Thanks.......
          <message edited by srinu_001241 on Thursday, November 24, 2011 9:35 PM>
           
          #5
            gadflyyy

            • Total Posts : 5
            • Scores: 0
            • Reward points : 0
            • Joined: 11/23/2011
            • Status: offline
            Re:excel.exe still remains in task manager after using vbs to close and quit Monday, November 28, 2011 2:52 PM (permalink)
            0
            Dear friends,
            Thank all for your kindly replies, I tried the solutions you provided, but it's a pity that the problem still exists.
             
            the code I tried:
             'Excel2pdm.vbs, Import Excel table to pdm 
            Option Explicit dim rwIndex    
            dim tableName 
            dim colname 
            dim table 
            dim col 
            Dim mdl ' the current model 
            Dim xlApp 'As Excel.Application 
            Dim xlBook 
            Dim xlSheet   Set mdl = ActiveModel 
            If (mdl Is Nothing) Then 
               MsgBox "There is no Active Model" 
            End If   set table = mdl.Tables.CreateNew 
            table.Name = "table_name"   
            table.Code = "DIM_CURRIER"  Set xlApp = CreateObject("Excel.Application") 
            xlApp.Visible = false 
            Set xlBook = xlApp.Workbooks.Open("E:\xfm\PowerDesigner_Training\gsm.xls")     
            set xlSheet =  xlApp.Workbooks(1).Worksheets(1)   
            xlSheet.Activate    For rwIndex = 3 To 6   
                set col = table.Columns.CreateNew     
                 col.Name = xlSheet.Cells(rwIndex,5).Value        
                 col.Code = xlSheet.Cells(rwIndex, 1).Value   
                 col.DataType = xlSheet.Cells(rwIndex, 2).Value  
                 col.Comment = xlSheet.Cells(rwIndex, 5).Value      
            Next  ' Close Excel and spreadsheet.  
              Set xlSheet = Nothing         
              If Not xlBook Is Nothing Then 
                  xlBook.Save 
                  xlBook.Close 
                 Set xlBook = Nothing 
              End If 
               
              If Not xlApp Is Nothing Then 
                 xlApp.Quit 
                 Set xlApp = Nothing 
              End if  
             msgbox "close the excel process!" 

             
            And the image as attachment: 
             
              
             Wish the problem can be resolved ASAP, and I believe this will be useful to others.
            Thank you again!
            <message edited by gadflyyy on Monday, November 28, 2011 2:57 PM>
             
            #6
              59cobalt

              • Total Posts : 981
              • Scores: 91
              • Reward points : 0
              • Joined: 7/17/2011
              • Status: offline
              Re:excel.exe still remains in task manager after using vbs to close and quit Tuesday, November 29, 2011 10:39 AM (permalink)
              0
              Try setting xlApp.Visible = True, so you see what's going on.
               
              #7
                gadflyyy

                • Total Posts : 5
                • Scores: 0
                • Reward points : 0
                • Joined: 11/23/2011
                • Status: offline
                Re:excel.exe still remains in task manager after using vbs to close and quit Tuesday, November 29, 2011 9:02 PM (permalink)
                0
                Thank you, 59cobalt, U r so kind.
                 
                I add  xlApp.Visible = True after Set xlApp = CreateObject("Excel.Application") ,
                Strangely, the excel doc. can be opened when the vbscript ran, and then closed itself as the program finished, BUT the EXCEL.EXE still remain in the Task Manager. Why?
                 
                Many thaks for your patient reply
                 
                  
                 
                #8
                  59cobalt

                  • Total Posts : 981
                  • Scores: 91
                  • Reward points : 0
                  • Joined: 7/17/2011
                  • Status: offline
                  Re:excel.exe still remains in task manager after using vbs to close and quit Wednesday, November 30, 2011 7:10 AM (permalink)
                  0
                  Weird. Apparently your code doesn't raise any error and correctly quits the application. After you set xlApp = Nothing the process should properly terminate. However, apparently something does prevent it from doing so.
                  I don't know what your ActiveModel and Table objects are, but did you try cleaning those up? Also check the application eventlog for errors/warnings, and perhaps the Excel process for open handles (e.g. with Process Explorer).
                   
                  #9
                    gadflyyy

                    • Total Posts : 5
                    • Scores: 0
                    • Reward points : 0
                    • Joined: 11/23/2011
                    • Status: offline
                    Re:excel.exe still remains in task manager after using vbs to close and quit Wednesday, November 30, 2011 3:13 PM (permalink)
                    0
                    OK, I will try some other methods,,
                    Any progress will  be post here.
                    Thank you again, my friend, best regards!
                     
                    #10
                      gadflyyy

                      • Total Posts : 5
                      • Scores: 0
                      • Reward points : 0
                      • Joined: 11/23/2011
                      • Status: offline
                      Re:excel.exe still remains in task manager after using vbs to close and quit Wednesday, December 14, 2011 9:48 PM (permalink)
                      0
                      Got the reason.
                      The VB script has no problem.
                      A  bug of PowerDesigner v15.1 cause the problem
                      I tried v15.3, no exception occurs, excel.exe disappeared as the program ran over.
                       
                       
                      #11
                        59cobalt

                        • Total Posts : 981
                        • Scores: 91
                        • Reward points : 0
                        • Joined: 7/17/2011
                        • Status: offline
                        Re:excel.exe still remains in task manager after using vbs to close and quit Sunday, December 18, 2011 7:03 AM (permalink)
                        0
                        Thanks for letting us know what caused the issue. Glad you got it resolved.
                         
                        #12

                          Online Bookmarks Sharing: Share/Bookmark

                          Jump to:

                          Current active users

                          There are 0 members and 1 guests.

                          Icon Legend and Permission

                          • New Messages
                          • No New Messages
                          • Hot Topic w/ New Messages
                          • Hot Topic w/o New Messages
                          • Locked w/ New Messages
                          • Locked w/o New Messages
                          • Read Message
                          • Post New Thread
                          • Reply to message
                          • Post New Poll
                          • Submit Vote
                          • Post reward post
                          • Delete my own posts
                          • Delete my own threads
                          • Rate post

                          2000-2012 ASPPlayground.NET Forum Version 3.9