| 
	
 Hello, 
I've been using Dragon NaturallySpeaking for a number of years now, and I recently started experimenting with WSR and its macro capability. I've managed to make a few XML-based macros with the help of Brad's extremely helpful "User's Guide," and over the last few days I've been trying to learn how to use VBScript within macros. I picked up a beginner's VBScript programming book at the library, read the first 100 pages, and thought I'd try modifying the following DNS command to work as a VBScript macro with WSR. The command opens an Outlook 2007 attachment by its number. I didn't write the command; I got it from another speech recognition forum and modified it to work the way I want it to. Here's the VBA code: 
Sub Main     Dim Att As Attachment     Dim msg As MailItem     Dim attachmentname As String 
    SendKeys "^o",1  'open the mail message 
    Set msg = ActiveInspector.CurrentItem     Set Att = msg.Attachments.Item(CInt(ListVar1))     attachmentname = Environ$("TEMP") + "/" + Att.FileName     Att.SaveAsFile(attachmentname) 
    SendKeys "%{F4}" 'close the mail message 
    ShellExecute attachmentname, 1, "", "Attachment"     Set msg=Nothing     Set Att=Nothing End Sub 
I rewrote the code as shown below. The first problem I encountered was that my attempts (now commented out) to instantiate the WScript.Shell object resulted in the error, "Object required: WScript." It seems like a really basic command like that ought to work on my Vista Business system. Is there something else I'm supposed to install on my computer before I attempt to write, run, and debug VBScripts? 
So I commented out the two WScript.Shell lines and kept going. (I later found out that I can use Application.SendKeys instead of the WshShell object's SendKeys statement, so maybe I won't need to instantiate this object anyway.) The next error I got was for the "msg = objOutlook.ActiveInspector.CurrentItem" line, as follows: 
 Object doesn't support this property or method: 'msg' 
Again, this statement seems pretty straightforward. I get the feeling like there's something missing that out to have installed first before I started trying to write VBScripts. Any advice? Thanks. 
-Russ 
<command> <listenFor>open attachment [AttachNum]</listenFor> <script language="VBScript">  <![CDATA[ Dim Att, msg, attachmentname, objWshObject, objOutlook 
    Set objOutlook = GetObject(, "Outlook.Application")     'Set objWshObject = GetObject(, "WScript.Shell")     'Set objWshObject = WScript.CreateObject("WScript.Shell") 
    Application.SendKeys("{{CTRL}}o") 'open the mail message 
    msg = objOutlook.ActiveInspector.CurrentItem     Att = objOutlook.msg.Attachments.Item(CInt({[AttachNum]}))     attachmentname = objWshObject.ExpandEnvironmentStrings("TEMP") & "/" & Att.FileName     Application.Att.SaveAsFile(attachmentname) 
    Application.SendKeys("{{ALT}}{F4}")  'close the mail message 
    ShellExecute attachmentname, 1, "", "Attachment" 'need to find VBScript command equivalent     msg=Nothing     Att=Nothing ]]> </script> </command> <numbers name="AttachNum" start="1" stop="9"/>
  
          |