Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
JGOV JGOV is offline
external usenet poster
 
Posts: 2
Default Word 2003 MailMerge Question - Fillin Fields

Hi, I think I am in the right place for this question so here goes. I am
automating mail merge using word 2003 object model. My question is, is there
a way to suppress the fillin field prompt? I do not have access to change
the templates and do not have access to the datasource and this process must
be completely without user input. Here is my current code.



//Open Template Document
Dim WordDoc As Word.Document = p_WordApp.Documents.Open(sPath + "\" + sFile)

//Open DataSource Document
WordDoc.MailMerge.OpenDataSource(Name:=sPath + "\Datasource" + sFile +
".csv", ReadOnly:=False, LinkToSource:=False, Connection:="",
SQLStatement:="", SQLStatement1:="")

//Verify DataSource has correct fields per its corresponding template
If VerifyMergeFields(WordDoc) Then

With .MailMerge

..Destination = Word.WdMailMergeDestination.wdSendToNewDocument

..SuppressBlankLines = True

With .DataSource

..FirstRecord = Word.WdMailMergeDefaultRecord.wdDefaultFirstRecord

..LastRecord = Word.WdMailMergeDefaultRecord.wdDefaultLastRecord

End With

..Execute(Pause:=False) -- Prompts Occur Here

End With

//Save and Close merged Document

p_WordApp.ActiveDocument.SaveAs(sPath + "\MergedDoc" + sFile)

p_WordApp.ActiveDocument.Close()

//Close template Document

WordDoc.Close(False, False)

WordDoc = Nothing



//Check for Error Documents since pause was set to False and save/close
them.

For Each oDocument As Word.Document In p_WordApp.Documents

If Not
Directory.Exists(Path.GetDirectoryName(Reflection. Assembly.GetExecutingAssembly.Location) & "\ErrorLog") Then

Directory.CreateDirectory(Path.GetDirectoryName(Re flection.Assembly.GetExecutingAssembly.Location) & "\ErrorLog")

End If

oDocument.SaveAs(Path.GetDirectoryName(Reflection. Assembly.GetExecutingAssembly.Location) & "\ErrorLog\" & sFile & "_" & oDocument.Name & ".Doc")

oDocument.Close()

Next



//Remove unneeded datasource and template

File.Delete(sPath + "\Datasource" + sFile + ".csv")

File.Delete(sPath + "\" + sFile)

End If

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Word 2003 MailMerge Question - Fillin Fields

What is the purpose of the Fillin Fields in the mail merge main document?
If they are superfluous, you could insert some code into your routine to
iterate through all of the fields in the document and either link, lock or
delete the Fillin fields.

--
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

"JGOV" wrote in message
...
Hi, I think I am in the right place for this question so here goes. I am
automating mail merge using word 2003 object model. My question is, is
there
a way to suppress the fillin field prompt? I do not have access to change
the templates and do not have access to the datasource and this process
must
be completely without user input. Here is my current code.



//Open Template Document
Dim WordDoc As Word.Document = p_WordApp.Documents.Open(sPath + "\" +
sFile)

//Open DataSource Document
WordDoc.MailMerge.OpenDataSource(Name:=sPath + "\Datasource" + sFile +
".csv", ReadOnly:=False, LinkToSource:=False, Connection:="",
SQLStatement:="", SQLStatement1:="")

//Verify DataSource has correct fields per its corresponding template
If VerifyMergeFields(WordDoc) Then

With .MailMerge

.Destination = Word.WdMailMergeDestination.wdSendToNewDocument

.SuppressBlankLines = True

With .DataSource

.FirstRecord = Word.WdMailMergeDefaultRecord.wdDefaultFirstRecord

.LastRecord = Word.WdMailMergeDefaultRecord.wdDefaultLastRecord

End With

.Execute(Pause:=False) -- Prompts Occur Here

End With

//Save and Close merged Document

p_WordApp.ActiveDocument.SaveAs(sPath + "\MergedDoc" + sFile)

p_WordApp.ActiveDocument.Close()

//Close template Document

WordDoc.Close(False, False)

WordDoc = Nothing



//Check for Error Documents since pause was set to False and save/close
them.

For Each oDocument As Word.Document In p_WordApp.Documents

If Not
Directory.Exists(Path.GetDirectoryName(Reflection. Assembly.GetExecutingAssembly.Location)
& "\ErrorLog") Then

Directory.CreateDirectory(Path.GetDirectoryName(Re flection.Assembly.GetExecutingAssembly.Location)
& "\ErrorLog")

End If

oDocument.SaveAs(Path.GetDirectoryName(Reflection. Assembly.GetExecutingAssembly.Location)
& "\ErrorLog\" & sFile & "_" & oDocument.Name & ".Doc")

oDocument.Close()

Next



//Remove unneeded datasource and template

File.Delete(sPath + "\Datasource" + sFile + ".csv")

File.Delete(sPath + "\" + sFile)

End If



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
JGOV JGOV is offline
external usenet poster
 
Posts: 2
Default Word 2003 MailMerge Question - Fillin Fields

Well i do have code in there to iterate through all the fields and unlock all
the ones that were locked because it was giving errors that it couldn't
update the locked fields. I did notice that even though the fields were
locked it would still prompt the user for the information. So I believe that
your suggestion in deleteing the fillin fields would be the best route since
we just press enter and send the fillins blank input anyways.

You did mention linking the fields. Does this mean that we could fill them
in with data from a preset souce so we don't have to press enter through them
all?

"Doug Robbins - Word MVP" wrote:

What is the purpose of the Fillin Fields in the mail merge main document?
If they are superfluous, you could insert some code into your routine to
iterate through all of the fields in the document and either link, lock or
delete the Fillin fields.

--
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

"JGOV" wrote in message
...
Hi, I think I am in the right place for this question so here goes. I am
automating mail merge using word 2003 object model. My question is, is
there
a way to suppress the fillin field prompt? I do not have access to change
the templates and do not have access to the datasource and this process
must
be completely without user input. Here is my current code.



//Open Template Document
Dim WordDoc As Word.Document = p_WordApp.Documents.Open(sPath + "\" +
sFile)

//Open DataSource Document
WordDoc.MailMerge.OpenDataSource(Name:=sPath + "\Datasource" + sFile +
".csv", ReadOnly:=False, LinkToSource:=False, Connection:="",
SQLStatement:="", SQLStatement1:="")

//Verify DataSource has correct fields per its corresponding template
If VerifyMergeFields(WordDoc) Then

With .MailMerge

.Destination = Word.WdMailMergeDestination.wdSendToNewDocument

.SuppressBlankLines = True

With .DataSource

.FirstRecord = Word.WdMailMergeDefaultRecord.wdDefaultFirstRecord

.LastRecord = Word.WdMailMergeDefaultRecord.wdDefaultLastRecord

End With

.Execute(Pause:=False) -- Prompts Occur Here

End With

//Save and Close merged Document

p_WordApp.ActiveDocument.SaveAs(sPath + "\MergedDoc" + sFile)

p_WordApp.ActiveDocument.Close()

//Close template Document

WordDoc.Close(False, False)

WordDoc = Nothing



//Check for Error Documents since pause was set to False and save/close
them.

For Each oDocument As Word.Document In p_WordApp.Documents

If Not
Directory.Exists(Path.GetDirectoryName(Reflection. Assembly.GetExecutingAssembly.Location)
& "\ErrorLog") Then

Directory.CreateDirectory(Path.GetDirectoryName(Re flection.Assembly.GetExecutingAssembly.Location)
& "\ErrorLog")

End If

oDocument.SaveAs(Path.GetDirectoryName(Reflection. Assembly.GetExecutingAssembly.Location)
& "\ErrorLog\" & sFile & "_" & oDocument.Name & ".Doc")

oDocument.Close()

Next



//Remove unneeded datasource and template

File.Delete(sPath + "\Datasource" + sFile + ".csv")

File.Delete(sPath + "\" + sFile)

End If




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2003 Mailmerge €“ Address fields Mary Ann Mailmerge 4 June 15th 07 08:26 AM
how do I stop a table disappearing when I use word fillin fields DianeG Microsoft Word Help 0 March 19th 07 03:49 PM
Order of fields in the mailmerge recipient list in Word 2003 Dan Newcombe Mailmerge 3 October 9th 06 05:35 PM
how do I set up mandatory 'fillin' fields in word Lori Microsoft Word Help 0 September 20th 05 10:15 PM
Fillin fields Marianne Microsoft Word Help 1 April 9th 05 07:42 AM


All times are GMT +1. The time now is 12:10 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"