Alpha Video Training
Results 1 to 5 of 5

Thread: Multiple instances of Word

  1. #1
    Member
    Real Name
    Shaun K
    Join Date
    Jan 2001
    Posts
    139

    Default Multiple instances of Word

    In v5 we can merge with both Excel or Word. But each merge opens a new instance of that program. How would I, in psudocode:

    Test if Word is open,
    If YES it is already open,
    Do not open a new instance of Word,
    Just do the mail merge.

    If NO, Word is NOT open
    Then DO open a new instance Word
    And do the mail merge.

    ... and where would I put the code?
    ... or does v5 have a genie to show me this?

    Thanks.

  2. #2
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,299

    Default RE: Multiple instances of Word

    you would have to write your own function in xbasic using a5's ole automation features.

    i will give you the source code that a5 is currently using for the word mail merge feature, and you can use that as a starting point.

    this function is used internally by a5 when you use the word mailmerge feature. as you can see, the underlying code for this feature is actually written in xbasic.
    -------------------------------

    function a5_word_merge as l(choice as c, mergedata as c, template = "")
    'DESCRIPTION:Mailmerge into Microsoft Word. Choice = "new" or "template" for an existing template. Mergedata is a comma delimited txt fie.
    'LIMITATIONS:X

    dim app as p
    dim doc as p
    dim merge as p

    app = ole.create("Word.Application")

    if choice = "new"

    doc = app.documents.add() 'open new document
    merge = doc.MailMerge()

    merge.MainDocumentType = 0 'turn document into a merge doc

    merge.OpenDataSource(mergedata) 'set data source

    app.visible = .t. 'make Word visible
    app.activate()

    else if choice = "template"

    if template ""

    on error goto template_open
    dim f as p
    f = file.open(template,FILE_RW_EXCLUSIVE)
    f.close()
    on error goto 0

    doc = app.documents.open(template) 'open template
    merge = doc.mailmerge()

    merge.OpenDataSource(mergedata) 'set data source

    merge.destination = 0 'merge into a new document
    merge.execute(.t.) 'merge!

    doc.close()
    app.visible = .t. 'make Word visible
    app.activate()
    end if

    end if
    end

    template_open:
    ui_msg_box("Error","Word Template document is in use. Please close the Template in Word, then try again.",UI_STOP_SYMBOL)
    exit function



    end function

  3. #3
    Member
    Real Name
    Shaun K
    Join Date
    Jan 2001
    Posts
    139

    Default RE: Multiple instances of Word

    Thanks Selwyn.

    Phew! I'd better get my homework books out!

  4. #4
    Member
    Real Name
    Shaun K
    Join Date
    Jan 2001
    Posts
    139

    Default RE: Multiple instances of Word

    Actually, I wouldn't need Word at all if Alpha's w/processor could mimic Word's "table" function. (Not a database table, more a layout tool.)

    Would I be right in beleiving Alpha intend to add this to v6 or as a freebie upgrade along the way? (Hint hint!)

  5. #5
    "Certified" Alphaholic
    Real Name
    William Hanigsberg
    Join Date
    Apr 2000
    Location
    Toronto, ON
    Posts
    4,018

    Default RE: Multiple instances of Word

    Shaun,

    When you write"...if Alpha's w/processor could mimic Word's 'table' function" do you mean with cells surrounded by a grid?

    If so you should be able to do that with lines, frames and borders in the report writer.

    Bill

Similar Threads

  1. Multiple Instances same window
    By gagsoft in forum Alpha Five Version 6
    Replies: 3
    Last Post: 05-12-2005, 10:06 AM
  2. report - multiple instances of records
    By dik_coleman in forum Alpha Five Version 6
    Replies: 2
    Last Post: 01-12-2005, 08:30 AM
  3. Multiple instances of runtime on one PC
    By Frank R in forum Alpha Five Version 5
    Replies: 4
    Last Post: 06-01-2004, 08:54 AM
  4. Two instances of A4v8?
    By Paul H in forum Alpha Four Versions 7 and 8
    Replies: 2
    Last Post: 10-06-2003, 12:32 PM
  5. Mailmerge in WORD - multiple opening of program
    By Jeremy Packman in forum Alpha Five Version 5
    Replies: 4
    Last Post: 05-14-2003, 06:31 PM

Bookmarks

Posting Permissions

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