sandam
02-03-2005, 03:32 AM
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)
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
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)
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