Consulting

Results 1 to 9 of 9

Thread: Getting a variable from one program back to Outlook

  1. #1
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location

    Getting a variable from one program back to Outlook

    I have a script, which works as follows.
    When a new email arrives, open a secondary program, run a script within that program, then close the program.

    This works, and works really well.

    However, once the script has run, I need to be able to return a variable from the secondary programs script back to within Outlook, so I can use the information to something else.

    I'm sure it can be done, but I seem to be suffering "brain-freeze" this morning.

    Can anyone help tell me how I pass the variable back to outlook?

    Thanks

  2. #2
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    How do you start the script ? From within outlook. You can define a rule that needs to run a vba macro where you call the external program. Once this is finished, the vba macro continues.

    Charlize

  3. #3
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location
    Charlize,
    The secondary program (Reflection) uses sessions. So the code within Outlook will look like this.
    [vba]Set objCL = New Reflection.Session
    With objCL
    .RunMacro "mySessionScript.MyMacro", ""
    End with
    [/vba]

    Can you help me furhter, with this information?

  4. #4
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    I'm not familiair with that reflection stuff. But can't you save the value of your variable in a textfile (within your reflection coding). In outlook you can look for that file, if it exists, read it and store the value in a variable to use and maybe kill the file from your disk ?

    Charlize

  5. #5
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    If it's a terminal screen ...
    ex.
    First Name: John
    ID: 456789
    Phone: 555-1212

    you could use
    [VBA]Dim customerName As String
    Dim customerID As String
    'maybe the New must be Get or something else to get current terminal session
    Set objCL = New Reflection.Session
    With objCL
    customerName = .GetText(5, 12, 5, 23)
    customerID = .GetText(6, 5, 6, 10)
    End With[/VBA]
    This means, get me the string for customer at line 5 from column 12 to line 5 and column 23 (name = 11 characters long) and get me customerid from line 6, column 5 (included) to line 6 to column 10 (included)(6 long)

    Charlize

  6. #6
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location
    I think maybe I haven't expressed my needs well enough.

    The following code runs within Outlook. Essentially what it does is run a macro within the reflection session. The marco (mySessionScript.MyMacro) will generate a series of variables.
    It is these variables that I need to report back to Outlook so that Outlook can use them later within it's own macro.

    [VBA]
    Set objCL = New Reflection.Session
    With objCL
    .RunMacro "mySessionScript.MyMacro", ""
    End With
    [/VBA]

  7. #7
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    You have to alter the code of your reflection macro. Add a write to file routine for your variables. When outlook goes further with the code, it looks for that file and after reading it, it deletes the file from you disk (but you have the data of those variables in outlook).

    Charlize

  8. #8
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location
    I'm really looking for a solution to be able to pass a variable from one program directly to another, without the need to create a file. But if that is the only solution, then I will have to try to rewrite the code, instead.

  9. #9
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Another option could be using environmental variables (path, username, ...). The ones we used to declare in bat-files and alike. Vba can read those to. But without you willing to share the coding (or the parts that need some tweaking) you use, it's difficult to produce something else then hypothetical solutions.

    Charlize

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •