DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX can't create object when VB Script called from Labview

I have an interesting issue that I can't find a solution for. I am using the DIAdem Run Script.VI in Labview to call a script that opens an Outlook object and sends an email. When the script is called via LabView I get this error:

 010912 10.04 AM.png

However, when I manually run the script from the DIAdem script tab it works as expected with no errors.

 

This is the code:

  'Begin email send function
  Dim oOutlookApp
  Dim oOutlookMail
  Dim cnByValue     : cnByValue = 1
  Dim cnMailItem    : cnMailItem = 0
 
  ' Get Outlook Application Object
  Set oOutlookApp = CreateObject("Outlook.Application")

 
  ' Create Mail Item
  Set oOutlookMail = oOutlookApp.CreateItem(cnMailItem)
 
  ' Set Mail Values
  With oOutlookMail
    .To      = "name@company.net"
    .Subject = "Report: " & Data.Root.ActiveChannelGroup.Name & " for " & CurrDate
    .Body    = "test automatic report emailing with VB Script."
 
    ' Add Attachement
    Call .Attachments.Add(strLocFileName, cnByValue, 1 )

    ' Send Mail
    Call .Send()
  End With

 (Original code includes Option Explicit and all variables are properly included/declared, I just took the snippet of what's causing the error).

 

I have looked at the following threads for info already:


http://forums.ni.com/t5/DIAdem/Some-errors-when-calling-LabVIEW-VIs-Interactively-from-DIAdem/td-p/2...

 

http://forums.ni.com/t5/DIAdem/Active-X-component-cannot-create-object-Diadem-8-1/m-p/71212/highligh...

-I tried running the script via Windows explorer (per Brad's suggestion) by itself without the DIAdem specific functions and it runs fine.


http://forums.ni.com/t5/DIAdem/Error-while-runing-diadem-asynchronous-script-from-labview-on/m-p/111...

-I am not running the scripts asynchronously

 

 

Using Windows 7 (64bit), DIAdem 11.2 and LabView 7.1.1

 

Thank you.

 

 

0 Kudos
Message 1 of 5
(4,964 Views)

I found the issue, for some reason when Outlook is already open the script will NOT run correctly when called from the Labview VI but when it is called from the DIAdem script editor everything works fine even if Outlook is open. Maybe someone can shed some light on this? Has something do with creating an object that already exists?

0 Kudos
Message 2 of 5
(4,945 Views)

Hey techerdone -

 

I'm afraid I personally can't be of much help - I tested your code both from DIAdem and from LabVIEW and each worked without issues in both cases (Outlook closed, Outlook open).  I'm using DIAdem 2011 SP1, LabVIEW 2011, and Outlook 2007...

Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 3 of 5
(4,927 Views)

Are you on a 32bit or 64bit machine?

0 Kudos
Message 4 of 5
(4,925 Views)

Hey techerdone - I am also running a 64-bit version of Windows 7.

 

Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 5 of 5
(4,911 Views)