| View previous topic :: View next topic |
| Author |
Message |
cdjones
Joined: 15 Sep 2009 Posts: 67 Location: Ga, USA
|
Posted: Mon Sep 21, 2009 12:59 am Post subject: COM add in, ws4ahk issue [solved] |
|
|
Hi all,
I'm trying to search thru outlook contacts from ahk.
I've got a working outllook macro that I'm trying to import. The following definitions will not even load. Gives an odd error.
| Code: | #include ws4ahk.ahk
; Body or HTMLBody combined with Display "destroys" the signature
VBScript =
(
msgbox "running"
Dim o As New Outlook.Application
Dim ns As Outlook.Namespace
Dim fldr As Outlook.MAPIFolder
Dim ctcItems As Outlook.Items
Dim j As Integer
Set ns = o.GetNamespace("MAPI")
Set fldr = ns.GetDefaultFolder(olFolderContacts)
msgbox "pt1"
}
WS_Initialize()
msgbox init
WS_Exec(VBScript)
If errorlevel != 0
msgbox % errorlevel
WS_Uninitialize() |
Any help appreciated.
Last edited by cdjones on Mon Sep 21, 2009 5:11 pm; edited 1 time in total |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Mon Sep 21, 2009 4:09 am Post subject: |
|
|
While your code may work for Visual Basic for Applications, it isn't compatible with VBScript (they should be considered separate languages). If you put your code in a .vbs file and run it, you will get similar results.
A VBScript compatible version might look like this.
| Code: | msgbox "running"
Set o = CreateObject("Outlook.Application")
Set ns = o.GetNamespace("MAPI")
Set fldr = ns.GetDefaultFolder(10) ' olFolderContacts
msgbox "pt1" |
You probably need to learn more about the differences between VBScript and VB/VBA. _________________ -m35 |
|
| Back to top |
|
 |
cdjones
Joined: 15 Sep 2009 Posts: 67 Location: Ga, USA
|
Posted: Mon Sep 21, 2009 11:32 am Post subject: |
|
|
I think I'm getting the idea, but
| Code: | #include ws4ahk.ahk
VBScript =
(
msgbox "running"
Set o = CreateObject("Outlook.Application")
Set ns = o.GetNamespace("MAPI")
Set fldr = ns.GetDefaultFolder(10)
msgbox "pt1"
}
WS_Initialize()
msgbox init
WS_Exec(VBScript)
If errorlevel != 0
msgbox % errorlevel
WS_Uninitialize() |
For a test.vbs I get both msgbox. For ahk I get "Error at Line 3.....Missing")" |
|
| Back to top |
|
 |
YMP
Joined: 23 Dec 2006 Posts: 418 Location: Russia
|
Posted: Mon Sep 21, 2009 12:46 pm Post subject: |
|
|
Yes, because you used "}", not ")".  |
|
| Back to top |
|
 |
cdjones
Joined: 15 Sep 2009 Posts: 67 Location: Ga, USA
|
Posted: Mon Sep 21, 2009 12:56 pm Post subject: |
|
|
Duh !
Thanks
Ok, now this works.
Anyway to avoid the warning from outlook that something is trying to access it ?
I'm on XP w office 2003 ? |
|
| Back to top |
|
 |
|