View Single Post
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
JJ[_2_] JJ[_2_] is offline
external usenet poster
 
Posts: 2
Default Create MailMerge Template from external application

Hello NG

Using VS2008 C# and Office 2007

I want to create a template using my own application.
I have setup an OfficeDataConnection file (.odc) the i use for the mailmerge
datasource.

Everyting looks OK but when i open the template Word is giving me this
message:
Word has encountered a problem.
There is a problem saving the file.

Usually this is because the disk or floppy disk is too small for the file or
is full, RAM memory is low, or there is a permission problem with the drive
the file is being saved to.

If the amount of disk space for a paging file is low, save the file to
another drive. If the RAM memory is low, increase available RAM. If
permissions to the drive do not allow you to save to that drive, save the
file to another drive or request permissions from the administrator to save
files to the drive.

Note: This error can also occur if the computer is running a version of
antivirus software that is not compatible with the Microsoft Office system
or needs to be updated.

If I open the file as Template (you know - right click and click OPEN) I'll
get this.
Word experienced an error trying to open the file.
Try these suggestions. bla. bla.

Kind regards

Johnny E. Jensen

I do the following in my code.

Imports WD = Microsoft.Office.Interop.Word

Public Class WordWrapper

Public Sub CreateTemplate(ByVal Filename As String)

Dim app As WD.Application

app = New WD.Application

app.ScreenUpdating = True

app.Visible = True

Dim objDoc As WD.Document

objDoc = app.Documents.Add()

Dim objName As Object = "C:\Documents and Settings\JEJ.ANDEBY\My
Documents\My Data Sources\vwCustomers.odc"

objDoc.MailMerge.MainDocumentType =
Microsoft.Office.Interop.Word.WdMailMergeMainDocTy pe.wdFormLetters

objDoc.MailMerge.Destination =
Microsoft.Office.Interop.Word.WdMailMergeDestinati on.wdSendToNewDocument

objDoc.MailMerge.OpenDataSource(Name:=objName)

objDoc.SaveAs(FileName:=Filename,
FileFormat:=WD.WdSaveFormat.wdFormatTemplate)

End Sub

End Class