Reply
 
Thread Tools Display Modes
  #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


  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Create MailMerge Template from external application

Not sure I will be able to help, but...

Using VS2008 C# and Office 2007


Are you just controlling Word from C# using the object model, or are you
writing a VSTO application?

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.


1. is this a .dot, a .dotx or a .dotm? (Or is it actually a .docx or .docm)?
2. are you opening it, or creating a new .doc/.docx/.docm based on it?
3. Does it have any VBA macros in it, or does the normal.dotm on your
system have any, and if so, could it be trying to save something at that
point?
4. this problem definitely occurs when you are /opening/ this file?
5. what is the actual data source, i.e. the thing the .odc references?


Peter Jamieson

http://tips.pjmsn.me.uk

On 17/11/2009 01:09, JJ wrote:
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


  #3   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 Peter

My mistake was to save the template as wdFormatTemplate and not
wdFormatXMLTemplate, so after using the wdFormatXMLTemplate type it works
just fine.

Kind regards

Johnny E. Jensen


"Peter Jamieson" wrote in message
...
Not sure I will be able to help, but...

Using VS2008 C# and Office 2007


Are you just controlling Word from C# using the object model, or are you
writing a VSTO application?

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.


1. is this a .dot, a .dotx or a .dotm? (Or is it actually a .docx or
.docm)?
2. are you opening it, or creating a new .doc/.docx/.docm based on it?
3. Does it have any VBA macros in it, or does the normal.dotm on your
system have any, and if so, could it be trying to save something at that
point?
4. this problem definitely occurs when you are /opening/ this file?
5. what is the actual data source, i.e. the thing the .odc references?


Peter Jamieson

http://tips.pjmsn.me.uk

On 17/11/2009 01:09, JJ wrote:
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




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
MailMerge - Working application. Jon (UK) Mailmerge 3 October 8th 08 10:37 AM
Can I update a word-document based on an external template? Mikael Lindqvist Microsoft Word Help 2 May 27th 08 05:00 PM
Can I create MailMerge template without a Data Source? Tom Mailhot Mailmerge 2 November 26th 07 10:21 PM
External Insertion Point in a Template Lenny[_2_] Microsoft Word Help 2 April 19th 07 08:07 PM
How do I create an application using forms/template/fields? Word - Creating a Form with field, table Microsoft Word Help 2 April 23rd 06 04:26 AM


All times are GMT +1. The time now is 08:57 PM.

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"