AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COM add in, ws4ahk issue [solved]

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
cdjones



Joined: 15 Sep 2009
Posts: 67
Location: Ga, USA

PostPosted: Mon Sep 21, 2009 12:59 am    Post subject: COM add in, ws4ahk issue [solved] Reply with quote

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
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 101
Location: California

PostPosted: Mon Sep 21, 2009 4:09 am    Post subject: Reply with quote

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
View user's profile Send private message
cdjones



Joined: 15 Sep 2009
Posts: 67
Location: Ga, USA

PostPosted: Mon Sep 21, 2009 11:32 am    Post subject: Reply with quote

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
View user's profile Send private message
YMP



Joined: 23 Dec 2006
Posts: 418
Location: Russia

PostPosted: Mon Sep 21, 2009 12:46 pm    Post subject: Reply with quote

Yes, because you used "}", not ")". Wink
Back to top
View user's profile Send private message
cdjones



Joined: 15 Sep 2009
Posts: 67
Location: Ga, USA

PostPosted: Mon Sep 21, 2009 12:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group