AutoHotkey Community

It is currently May 26th, 2012, 9:42 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: September 21st, 2009, 1:59 am 
Offline

Joined: September 15th, 2009, 7:16 pm
Posts: 67
Location: Ga, USA
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 September 21st, 2009, 6:11 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2009, 5:09 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2009, 12:32 pm 
Offline

Joined: September 15th, 2009, 7:16 pm
Posts: 67
Location: Ga, USA
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")"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2009, 1:46 pm 
Offline

Joined: December 23rd, 2006, 6:02 pm
Posts: 424
Location: Russia
Yes, because you used "}", not ")". :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2009, 1:56 pm 
Offline

Joined: September 15th, 2009, 7:16 pm
Posts: 67
Location: Ga, USA
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 ?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, JSLover, patgenn123, rbrtryn, virpara, Yahoo [Bot] and 58 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group