Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Mon, 6 Oct 2008 06:44:34 -0700 (PDT),    group: microsoft.public.word.vba.general        back       


Suppress displaying of main merge document   
I have made a function to create a merged document. The merge can be
started from an application running on an iSeries server (a.k.a. AS/
400). The application first assembles some data, writes it to a comma-
separated file, and then uses a command to start Word. The -m switch
is used to automatically start a macro that will run the merge. When I
do this, the merged document is displayed on screen and can be printed
(or modified, if necessary) by the user. This is exactly what should
happen. However, the main document (the template for the merge) is
also opened. This is NOT what should happen. The user should just get
the merged document on screen. I have messed around a bit in VBA, but
I have not yet found a way to suppress the displaying of the main
document. I hope somebody can help me out!

Thanks in advance,

Ewout
date: Mon, 6 Oct 2008 06:44:34 -0700 (PDT)   author:   unknown

Re: Suppress displaying of main merge document   
Show us the code for your macro and we might be able to suggest how it can 
be modified.

-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"ewout.boter@home.nl"  wrote in message 
news:5e5abc22-5acd-44e7-aa8b-e4c4bfa03d56@t65g2000hsf.googlegroups.com...
>I have made a function to create a merged document. The merge can be
> started from an application running on an iSeries server (a.k.a. AS/
> 400). The application first assembles some data, writes it to a comma-
> separated file, and then uses a command to start Word. The -m switch
> is used to automatically start a macro that will run the merge. When I
> do this, the merged document is displayed on screen and can be printed
> (or modified, if necessary) by the user. This is exactly what should
> happen. However, the main document (the template for the merge) is
> also opened. This is NOT what should happen. The user should just get
> the merged document on screen. I have messed around a bit in VBA, but
> I have not yet found a way to suppress the displaying of the main
> document. I hope somebody can help me out!
>
> Thanks in advance,
>
> Ewout
date: Tue, 7 Oct 2008 16:15:34 +1000   author:   Doug Robbins - Word MVP

Re: Suppress displaying of main merge document   
The code of the macro is below. The code was to a large extent
generated when I recorded the macro.

Ewout

Sub InsurancePolicy()
'
' InsurancePolicy Macro
' Macro recorded 9/9/2008 by Boter
'
    Documents.Open FileName:="\\ainl1f001\inf$\data\Development
\InsurancePolicy\InsurancePolicyTemplate.doc", ConfirmConversions _
        :=False, ReadOnly:=True, AddToRecentFiles:=False,
PasswordDocument:="", _
        PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
        WritePasswordTemplate:="", Format:=wdOpenFormatAuto,
Visible:=True

    With ActiveDocument.MailMerge
        .Destination = wdSendToNewDocument
        .MailAsAttachment = False
        .MailAddressFieldName = ""
        .MailSubject = ""
        .SuppressBlankLines = True
        With .DataSource
            .FirstRecord = wdDefaultFirstRecord
            .LastRecord = wdDefaultLastRecord
        End With
        .Execute Pause:=True
    End With

End Sub

On Oct 7, 8:15 am, "Doug Robbins - Word MVP" 
wrote:
> Show us the code for your macro and we might be able to suggest how it can
> be modified.
>
> --
> Hope this helps.
>
date: Tue, 7 Oct 2008 02:37:12 -0700 (PDT)   author:   unknown

Re: Suppress displaying of main merge document   
Use

Sub InsurancePolicy()
'
' InsurancePolicy Macro
' Macro recorded 9/9/2008 by Boter
'
Dim maindoc as document
Set maindoc = Documents.Open 
(FileName:="\\ainl1f001\inf$\data\Development\InsurancePolicy\InsurancePolicyTemplate.doc"
With maindoc.MailMerge
        .Destination = wdSendToNewDocument
        With .DataSource
            .FirstRecord = wdDefaultFirstRecord
            .LastRecord = wdDefaultLastRecord
        End With
        .Execute Pause:=True
 End With
maindoc.Close wdDoNotSaveChanges

End Sub


-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"ewout.boter@home.nl"  wrote in message 
news:aee9b3b1-97e9-41b0-a13c-a45fe2bc193b@h60g2000hsg.googlegroups.com...
The code of the macro is below. The code was to a large extent
generated when I recorded the macro.

Ewout

Sub InsurancePolicy()
'
' InsurancePolicy Macro
' Macro recorded 9/9/2008 by Boter
'
    Documents.Open FileName:="\\ainl1f001\inf$\data\Development
\InsurancePolicy\InsurancePolicyTemplate.doc", ConfirmConversions _
        :=False, ReadOnly:=True, AddToRecentFiles:=False,
PasswordDocument:="", _
        PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
        WritePasswordTemplate:="", Format:=wdOpenFormatAuto,
Visible:=True

    With ActiveDocument.MailMerge
        .Destination = wdSendToNewDocument
        .MailAsAttachment = False
        .MailAddressFieldName = ""
        .MailSubject = ""
        .SuppressBlankLines = True
        With .DataSource
            .FirstRecord = wdDefaultFirstRecord
            .LastRecord = wdDefaultLastRecord
        End With
        .Execute Pause:=True
    End With

End Sub

On Oct 7, 8:15 am, "Doug Robbins - Word MVP" 
wrote:
> Show us the code for your macro and we might be able to suggest how it can
> be modified.
>
> --
> Hope this helps.
>
date: Tue, 7 Oct 2008 20:32:55 +1000   author:   Doug Robbins - Word MVP

Re: Suppress displaying of main merge document   
Doug,

That worked! Although I must say that I have added two options to the
Open command: ReadOnly:=True and Visible:=False. Without the
ReadOnly:=True, a Password window was displayed. I think this is a
result of the fact hat I have protected the document with a password.
Without the Visible:=False option, the main document was visible for a
very short time. With the current version of the macro, the main
document is not displayed at all.

Many thanks for your help!

Ewout

On Oct 7, 12:32 pm, "Doug Robbins - Word MVP"
 wrote:
> Use
>
> Sub InsurancePolicy()
> '
> ' InsurancePolicy Macro
> ' Macro recorded 9/9/2008 by Boter
> '
> Dim maindoc as document
> Set maindoc = Documents.Open
> (FileName:="\\ainl1f001\inf$\data\Development\InsurancePolicy\InsurancePoli­cyTemplate.doc"
> With maindoc.MailMerge
>         .Destination = wdSendToNewDocument
>         With .DataSource
>             .FirstRecord = wdDefaultFirstRecord
>             .LastRecord = wdDefaultLastRecord
>         End With
>         .Execute Pause:=True
>  End With
> maindoc.Close wdDoNotSaveChanges
>
> End Sub
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
date: Tue, 7 Oct 2008 05:29:44 -0700 (PDT)   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us