Consulting

Results 1 to 10 of 10

Thread: Solved: Two problems, can someone please help?

  1. #1
    Knowledge Base Approver
    Space Cadet
    VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location

    Unhappy Solved: Two problems, can someone please help?

    I am currently writing macros for word documents that are merged from our back office system. I can get the macros to work fine (except for my own programming errors ) but I need to be able to access the Outlook calendar of the user to add things to their todo lists etc as well as email letters if the option is selected. - this is problem number 1

    Problem number two realtes to excel and word. I currently use excel spreadsheets to hold lists of data that are used to populate combo boxes on forms, however I cannot get the excel process to die after I tell it to quit?
    This is the code (thanks to the other people on VBA who explained how to do it in the first place)


    [VBA]Private Sub cbxSender_DropButtonClick()

    Dim ObjExcel As Excel.Application
    Dim Wkb As Excel.Workbook
    Dim WS As Excel.Worksheet
    Dim SearchString As String
    Dim I As Integer
    Dim J As Integer
    Dim K As Integer

    Set ObjExcel = New Excel.Application
    Set Wkb = ObjExcel.Workbooks.Open(FileName:=myPath, ReadOnly:=True)
    Set WS = Wkb.Sheets("users")

    J = cbxSender.ListIndex
    If J >= 0 And ((J + 1) < cbxSender.ListCount) Then
    Let theUser.FullName() = WS.Range("A" & (J + 1)).Value & " " & _
    WS.Range("B" & (J + 1)).Value
    Let theUser.Initials() = WS.Range("C" & (J + 1))
    End If

    Wkb.Close Savechanges:=False
    ObjExcel.Quit

    Set ObjExcel = Nothing
    Set Wkb = Nothing
    Set WS = Nothing

    End Sub
    [/VBA]

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Are you using Office 97 per chance?

  3. #3
    Knowledge Base Approver
    Space Cadet VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location
    nope - office 2003

  4. #4
    Knowledge Base Approver
    Space Cadet VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location
    in windows xp

  5. #5
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Hmm... Strange that the Excel App will not quit. Try this code.

    [vba]
    Sub Test()

    Dim ObjExcel As Excel.Application

    Set ObjExcel = New Excel.Application

    ObjExcel.Quit

    Set ObjExcel = Nothing

    End Sub
    [/vba]
    Does Excel quit or do you still have a process running?

  6. #6
    Knowledge Base Approver
    Space Cadet VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location

    Question

    it quits now. what i dont understand is why it wont do it when I'm working inside the macros? I have to make the macros access the excel file over the network on our database server because they have to be able to run from multiple users. I only discovered this problem when my bosses tested what i'd done so far and noticed that there were extra excel processes left over in the task manager. the file is a CSV that is imported into excel from active directory (our users) - could this be the problem?

  7. #7
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    It could be a network issue not letting the Excel process quit. Instead of using [VBA]ObjExcel.Quit [/VBA] try [VBA]ObjExcel.Visible = True[/VBA]Then close it manually. Does that end the process?

  8. #8
    Knowledge Base Approver
    Space Cadet VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location

    Red face

    hmmmm It appears to kill the process but I will have to investigate further when the next round of testing happens (1 weeks time) but otherwise it looks like its working. I dont know, personally i think the PC's are just temperaMENTAL and the loading and unloading of processes is a mystery that even bill gates best can't truly solve properly.

    Thanks again for you help I'll get back to you about how its goes.

  9. #9
    Knowledge Base Approver
    Space Cadet VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location
    Quote Originally Posted by DRJ
    It could be a network issue not letting the Excel process quit. Instead of using [VBA]ObjExcel.Quit [/VBA] try [VBA]ObjExcel.Visible = True[/VBA]Then close it manually. Does that end the process?
    Hi again, it solved the problem thanks Got others now but that'll be a new post. Thanks Again

    Andrew;?

  10. #10
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Glad to help.

    Take Care

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •