Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ole excel outlook
Note that you'll need the 98D or newer versions of Winbatch for the OLE paste to work correctly.
;;;;;;;;;;;;;;;;;;;;;;;;SCRIPT #1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This first one just tries to paste "This is a test" into a cell in Excel MyXLObj = ObjectOpen("Excel.Application") MyXLObj.Visible = @TRUE MyWorkbooks = MyXLObj.Workbooks MyWorkbooks.add MyCell = MyXLObj.ActiveCell MyCell.Value = "This is a test" exit ;;;;;;;;;;;;;;;;;;;;;;;;SCRIPT #2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Add Companies ; This script searches for the company names associated with each of ; the contacts in a Journal Entry in Outlook and builds a string containing ; a single occurrance for each company. It then pastes the string into the ; companies field of the Journal Entry ;ErrorMode(@OFF) if WinExist("~- Journal Entry") then WinActivate("~- Journal Entry") while (StrIndex(WinGetActive(),"- Journal Entry",1,@FWDSCAN)==0) endwhile CurrentWindow=WinGetActive() WinZoom(CurrentWindow) MyApp = ObjectOpen("Outlook.Application") MyInspector = MyApp.ActiveInspector MyItem = MyInspector.CurrentItem MyClass = MyItem.Class MyRecipients = MyItem.Recipients MyNameSpace = MyApp.GetNameSpace("MAPI") MainFolder = MyNameSpace.Folders("Jim's Folders") MainFolderName = MainFolder.Name MyContacts = MainFolder.Folders("Full Contact List") MyContactsName = MyContacts.Name MyItems = MyContacts.Items count = MyRecipients.Count CompanyList = "" NumCompanies = 0 for i = 1 to count ErrorNum = 0 MyRecipient = MyItem.Recipients(i) MyAddress = MyRecipient.Address MySearchString = StrCat("[Email1Address] = ",MyAddress) MyContact = MyItems.Find(MySearchString) ErrorNum = LastError() If ErrorNum == 0 MyCompanyName = MyContact.CompanyName If StrIndex(CompanyList,MyCompanyName,1,@FWDSCAN) == 0 if NumCompanies 0 CompanyList = StrCat(CompanyList, ", ", MyCompanyName) NumCompanies = NumCompanies + 1 else CompanyList = MyCompanyName NumCompanies = 1 endif endif else if ErrorNum == 1261 else Message("Error", ErrorNum) exit endif endif next MyItem.Companies = CompanyList ; This is the line that >gives me jibberish > >I had to replace the last line with: > WinActivate(CurrentWindow) ; This activates the >Journal Entry SendKeysTo(CurrentWindow,"!a") ;This activates the >Companies field within the Jounal Entry in Outlook SendKeysTo(CurrentWindow,CompanyList) ; This types in the text exit
Article ID: W13673
Filename: OLE Excel and Outlook Examples.txt
File Created: 2000:04:20:17:04:58
Last Updated: 2000:04:20:17:04:58