[Migrated content. Thread originally posted on 13 November 2003]
Hello,
I am trying to determine the type of document I am opening to see if it is a Mail Merge Main Document. I am inquiring the @State of the document to determine the type of the document. In versions of Word prior to 2003, it would return the correct information, with Word 2003 it is always returning a "0" which signifies that its just a normal document. I have also tried inquiring the @MainDocumentType and with 2003 it just returns a -1 which means it not a mail merge document.
I'm letting the users select the mail merge main document and I want to make sure that it is a mail merge main document and not a regular word document. If I don't check the document type, and I choose a mail merge main document , my mail merge still works properly on all version of Word. If I allow them to select a "Normal" document I sometimes get errors with Word, which I don't want to happen.
Thanks for your help,
Scott
I find it interesting that both variants you have tried indicates this is a normal document, and you *know* it is a mailmerge template.
Usually, one failure means a bug, but when there are two... It is sort of more consistent, more trustworthy.
But, when you claim this has worked well with earlier versions, it is tempting to blame it on the new Office release.
One thing I thought about in an attempt to avoid errors, you could try to count the fields, assuming that if there were no fields, then it was probably a normal document.
It would be easier though, to investigate if I had some source to look at.
[Migrated content. Thread originally posted on 13 November 2003]
Hello,
I am trying to determine the type of document I am opening to see if it is a Mail Merge Main Document. I am inquiring the @State of the document to determine the type of the document. In versions of Word prior to 2003, it would return the correct information, with Word 2003 it is always returning a "0" which signifies that its just a normal document. I have also tried inquiring the @MainDocumentType and with 2003 it just returns a -1 which means it not a mail merge document.
I'm letting the users select the mail merge main document and I want to make sure that it is a mail merge main document and not a regular word document. If I don't check the document type, and I choose a mail merge main document , my mail merge still works properly on all version of Word. If I allow them to select a "Normal" document I sometimes get errors with Word, which I don't want to happen.
Thanks for your help,
Scott
I find it interesting that both variants you have tried indicates this is a normal document, and you *know* it is a mailmerge template.
Usually, one failure means a bug, but when there are two... It is sort of more consistent, more trustworthy.
But, when you claim this has worked well with earlier versions, it is tempting to blame it on the new Office release.
One thing I thought about in an attempt to avoid errors, you could try to count the fields, assuming that if there were no fields, then it was probably a normal document.
It would be easier though, to investigate if I had some source to look at.
[Migrated content. Thread originally posted on 13 November 2003]
Hello,
I am trying to determine the type of document I am opening to see if it is a Mail Merge Main Document. I am inquiring the @State of the document to determine the type of the document. In versions of Word prior to 2003, it would return the correct information, with Word 2003 it is always returning a "0" which signifies that its just a normal document. I have also tried inquiring the @MainDocumentType and with 2003 it just returns a -1 which means it not a mail merge document.
I'm letting the users select the mail merge main document and I want to make sure that it is a mail merge main document and not a regular word document. If I don't check the document type, and I choose a mail merge main document , my mail merge still works properly on all version of Word. If I allow them to select a "Normal" document I sometimes get errors with Word, which I don't want to happen.
Thanks for your help,
Scott
I find it interesting that both variants you have tried indicates this is a normal document, and you *know* it is a mailmerge template.
Usually, one failure means a bug, but when there are two... It is sort of more consistent, more trustworthy.
But, when you claim this has worked well with earlier versions, it is tempting to blame it on the new Office release.
One thing I thought about in an attempt to avoid errors, you could try to count the fields, assuming that if there were no fields, then it was probably a normal document.
It would be easier though, to investigate if I had some source to look at.
[Migrated content. Thread originally posted on 13 November 2003]
Hello,
I am trying to determine the type of document I am opening to see if it is a Mail Merge Main Document. I am inquiring the @State of the document to determine the type of the document. In versions of Word prior to 2003, it would return the correct information, with Word 2003 it is always returning a "0" which signifies that its just a normal document. I have also tried inquiring the @MainDocumentType and with 2003 it just returns a -1 which means it not a mail merge document.
I'm letting the users select the mail merge main document and I want to make sure that it is a mail merge main document and not a regular word document. If I don't check the document type, and I choose a mail merge main document , my mail merge still works properly on all version of Word. If I allow them to select a "Normal" document I sometimes get errors with Word, which I don't want to happen.
Thanks for your help,
Scott
In my test I know its a mail merge main document because I created it. When I walk it through the debugger using Word2000 I get the desired results.
Below is the code that I am using to test my document.
CREATE @Application OF @Word HANDLE IN WORD-APP.
MODIFY WORD-APP @Visible = 0.
MODIFY WORD-APP @Documents::Open(DOCUMENT-PATH,0,1) GIVING WORD-DOC.
INQUIRE WORD-DOC MAILMERGE IN WORD-MERGE.
INQUIRE WORD-MERGE @State IN DOC-STATE.
IF DOC-STATE = WDNORMALDOCUMENT OR DOC-STATE = WDDATASOURCE
DESTROY MERGING-WINDOW
DISPLAY MESSAGE BOX "The selected word document is not a mail merge "
"main document." TITLE "Invalid Document" ICON MB-ERROR-ICON
DESTROY WORD-MERGE
DESTROY WORD-DOC
MODIFY WORD-APP @Quit()
DESTROY WORD-APP
MOVE 1 TO ACCEPT-CONTROL
MOVE 3 TO CONTROL-VALUE
GO TO CL10.
If anyone has any other suggestions or ideas please let me know.
Scott
[Migrated content. Thread originally posted on 13 November 2003]
Hello,
I am trying to determine the type of document I am opening to see if it is a Mail Merge Main Document. I am inquiring the @State of the document to determine the type of the document. In versions of Word prior to 2003, it would return the correct information, with Word 2003 it is always returning a "0" which signifies that its just a normal document. I have also tried inquiring the @MainDocumentType and with 2003 it just returns a -1 which means it not a mail merge document.
I'm letting the users select the mail merge main document and I want to make sure that it is a mail merge main document and not a regular word document. If I don't check the document type, and I choose a mail merge main document , my mail merge still works properly on all version of Word. If I allow them to select a "Normal" document I sometimes get errors with Word, which I don't want to happen.
Thanks for your help,
Scott
I suspect there must be something wrong with your files somehow.
I ran the code below on the template.doc and datasource.doc that my MSWordMailMerge sample commented elsewhere in this forum creates.
And it produced the exact same output from Office 2002 and Office XP.
The output:
TEMPLATE.DOC: "Document type: Main and datasource doc"
DATASOURCE.DOC: "Document type: Normal document"
Both as expected.
The code:
IDENTIFICATION DIVISION.
PROGRAM-ID. WordMrg.
SPECIAL-NAMES.
COPY "WORD.DEF".
.
WORKING-STORAGE SECTION.
77 CNTL-FONT USAGE HANDLE OF FONT SMALL-FONT.
01 HANDLES.
03 wrdApp HANDLE OF APPLICATION.
03 wrdDoc HANDLE OF DocUMENT.
03 wrdMerge HANDLE OF MailMerge.
03 Doc-State pic 9(4).
03 text-str pic x(50).
03 FILENAME PIC X(50).
SCREEN SECTION.
01 INPUT-SCREEN.
03 LABEL
LINE 02
COL 02
TITLE "File:".
03 ENTRY-FIELD
LINE 02
COL 10
USING FILENAME.
03 FILE-TYPE.
05 LABEL
LINE 05
COL 20
TITLE TEXT-STR.
03 STATUS-BAR
TITLE "Blank filename terminates"
panel-style 1.
PROCEDURE DIVISION.
APP-MAIN SECTION.
APP-MAIN-001.
*Create the Word OLE object and instantiate a connection to it.
DISPLAY STANDARD GRAPHICAL WINDOW
TITLE "Template"
CONTROL FONT CNTL-FONT
SIZE 80
LINES 15
BACKGROUND-LOW.
CREATE APPLICATION OF WORD
HANDLE IN wrdApp.
INITIALIZE FILENAME
TEXT-STR.
DISPLAY INPUT-SCREEN.
APP-MAIN-010.
INITIALIZE wrdDoc
wrdMerge.
ACCEPT INPUT-SCREEN.
INITIALIZE TEXT-STR.
DISPLAY FILE-TYPE.
IF FILENAME = SPACE
GO TO APP-MAIN-020.
MODIFY wrdApp Documents::Open(FILENAME, 0, 1)
GIVING WrdDoc.
IF wrdDoc = NULL
GO TO APP-MAIN-010.
INQUIRE WrdDoc MailMerge IN WrdMerge.
INQUIRE WrdMerge @State IN Doc-STATE.
EVALUATE DOC-STATE
WHEN WdNormalDocument
STRING "Document type: "
"Normal document"
DELIMITED BY SIZE
INTO TEXT-STR
WHEN WdDataSource
STRING "Document type: "
"Datasource document"
DELIMITED BY SIZE
INTO TEXT-STR
WHEN wdMainDocumentOnly
STRING "Document type: "
"Main document"
DELIMITED BY SIZE
INTO TEXT-STR
WHEN wdMainAndDataSource
STRING "Document type: "
"Main and datasource doc"
DELIMITED BY SIZE
INTO TEXT-STR
WHEN wdMainAndHeader
STRING "Document type: "
"Main and header document"
DELIMITED BY SIZE
INTO TEXT-STR
WHEN wdMainAndSourceAndHeader
STRING "Document type: "
"Main, source and header doc"
DELIMITED BY SIZE
INTO TEXT-STR
WHEN wdDataSource
STRING "Document type: "
"Datasource document"
DELIMITED BY SIZE
INTO TEXT-STR
WHEN OTHER
STRING "Unknown doc type: "
DOC-STATE
DELIMITED BY SIZE INTO TEXT-STR
END-EVALUATE.
DESTROY WrdMerge.
MODIFY WrdDoc @Close().
DESTROY WrdDoc.
DISPLAY FILE-TYPE.
GO TO APP-MAIN-010.
APP-MAIN-020.
MODIFY wrdApp Quit().
Destroy WrdApp.
APP-MAIN-900.
STOP RUN.
APP-MAIN-EXIT.
EXIT.
[Migrated content. Thread originally posted on 13 November 2003]
Hello,
I am trying to determine the type of document I am opening to see if it is a Mail Merge Main Document. I am inquiring the @State of the document to determine the type of the document. In versions of Word prior to 2003, it would return the correct information, with Word 2003 it is always returning a "0" which signifies that its just a normal document. I have also tried inquiring the @MainDocumentType and with 2003 it just returns a -1 which means it not a mail merge document.
I'm letting the users select the mail merge main document and I want to make sure that it is a mail merge main document and not a regular word document. If I don't check the document type, and I choose a mail merge main document , my mail merge still works properly on all version of Word. If I allow them to select a "Normal" document I sometimes get errors with Word, which I don't want to happen.
Thanks for your help,
Scott
Hi Gisle,
I used your sample program and found some interesting results.
When I first run your program, with the file that I have attached, with word 2000, I received a result of "Main and data source".
When I tried to run the program with word 2003, the save dialoge box came up in word and then I got read only errors. I then changed the Open so that it now says "::Open(FILENAME)" so the file gets opened I-O. Now when I run the program with 2003 the program returns a "Normal Document" result.
Now when I try again with Word 2000, the program returns a "Normal Document" result.
Thanks for your help,
Scott:(
[Migrated content. Thread originally posted on 13 November 2003]
Hello,
I am trying to determine the type of document I am opening to see if it is a Mail Merge Main Document. I am inquiring the @State of the document to determine the type of the document. In versions of Word prior to 2003, it would return the correct information, with Word 2003 it is always returning a "0" which signifies that its just a normal document. I have also tried inquiring the @MainDocumentType and with 2003 it just returns a -1 which means it not a mail merge document.
I'm letting the users select the mail merge main document and I want to make sure that it is a mail merge main document and not a regular word document. If I don't check the document type, and I choose a mail merge main document , my mail merge still works properly on all version of Word. If I allow them to select a "Normal" document I sometimes get errors with Word, which I don't want to happen.
Thanks for your help,
Scott
Hi Gisle,
I used your sample program and found some interesting results.
When I first run your program, with the file that I have attached, with word 2000, I received a result of "Main and data source".
When I tried to run the program with word 2003, the save dialoge box came up in word and then I got read only errors. I then changed the Open so that it now says "::Open(FILENAME)" so the file gets opened I-O. Now when I run the program with 2003 the program returns a "Normal Document" result.
Now when I try again with Word 2000, the program returns a "Normal Document" result.
Thanks for your help,
Scott:(
[Migrated content. Thread originally posted on 13 November 2003]
Hello,
I am trying to determine the type of document I am opening to see if it is a Mail Merge Main Document. I am inquiring the @State of the document to determine the type of the document. In versions of Word prior to 2003, it would return the correct information, with Word 2003 it is always returning a "0" which signifies that its just a normal document. I have also tried inquiring the @MainDocumentType and with 2003 it just returns a -1 which means it not a mail merge document.
I'm letting the users select the mail merge main document and I want to make sure that it is a mail merge main document and not a regular word document. If I don't check the document type, and I choose a mail merge main document , my mail merge still works properly on all version of Word. If I allow them to select a "Normal" document I sometimes get errors with Word, which I don't want to happen.
Thanks for your help,
Scott
Hi Gisle,
I used your sample program and found some interesting results.
When I first run your program, with the file that I have attached, with word 2000, I received a result of "Main and data source".
When I tried to run the program with word 2003, the save dialoge box came up in word and then I got read only errors. I then changed the Open so that it now says "::Open(FILENAME)" so the file gets opened I-O. Now when I run the program with 2003 the program returns a "Normal Document" result.
Now when I try again with Word 2000, the program returns a "Normal Document" result.
Thanks for your help,
Scott:(
[Migrated content. Thread originally posted on 13 November 2003]
Hello,
I am trying to determine the type of document I am opening to see if it is a Mail Merge Main Document. I am inquiring the @State of the document to determine the type of the document. In versions of Word prior to 2003, it would return the correct information, with Word 2003 it is always returning a "0" which signifies that its just a normal document. I have also tried inquiring the @MainDocumentType and with 2003 it just returns a -1 which means it not a mail merge document.
I'm letting the users select the mail merge main document and I want to make sure that it is a mail merge main document and not a regular word document. If I don't check the document type, and I choose a mail merge main document , my mail merge still works properly on all version of Word. If I allow them to select a "Normal" document I sometimes get errors with Word, which I don't want to happen.
Thanks for your help,
Scott
Heres the file I was using.