PDA

View Full Version : Solved: Two problems, can someone please help?



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

Jacob Hilderbrand
02-03-2005, 03:34 AM
Are you using Office 97 per chance?

sandam
02-03-2005, 03:35 AM
nope - office 2003

sandam
02-03-2005, 03:36 AM
in windows xp

Jacob Hilderbrand
02-03-2005, 03:44 AM
Hmm... Strange that the Excel App will not quit. Try this code.


Sub Test()

Dim ObjExcel As Excel.Application

Set ObjExcel = New Excel.Application

ObjExcel.Quit

Set ObjExcel = Nothing

End Sub

Does Excel quit or do you still have a process running?

sandam
02-03-2005, 03:51 AM
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?

Jacob Hilderbrand
02-03-2005, 03:53 AM
It could be a network issue not letting the Excel process quit. Instead of using ObjExcel.Quit try ObjExcel.Visible = TrueThen close it manually. Does that end the process?

sandam
02-03-2005, 04:01 AM
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 :banghead: 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.:friends:

sandam
02-10-2005, 03:18 AM
It could be a network issue not letting the Excel process quit. Instead of using ObjExcel.Quit try ObjExcel.Visible = TrueThen 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;?

Jacob Hilderbrand
02-10-2005, 04:25 AM
Glad to help. :beerchug:

Take Care