Matthias005
05-28-2013, 03:00 AM
Hello,
I'm trying to use a word document as input for project specific information. This information is needed in multiple other Word documents so I am using the Mailmerge function. After you have filled in the word document you'll have to choose the language of the Word documents.I am making this with a document someone else already built. I am getting problems when changing the input fields and declarations of them.
This is my code so far:
Sub Projectplan()
ActiveDocument.SaveAs FileName:="C:\temp\Projectgegevens.txt", FileFormat:= _
wdFormatText, LockComments:=False, Password:="", AddToRecentFiles:= _
False, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=True, _
SaveAsAOCELetter:=False
Application.DisplayStatusBar = True
With ActiveDocument
.ReadOnlyRecommended = False
.EmbedTrueTypeFonts = False
.SaveFormsData = False
.SaveSubsetFonts = False
.Password = ""
.WritePassword = ""
End With
Dim opmdat As String
WordBasic.FileOpen Name:="C:\temp\Projectgegevens.txt"
WordBasic.Insert opmdat + Chr(10)
WordBasic.FileSave
WordBasic.FileClose 1
Keuzescherm.Show
End Sub
Sub Samenvoegen()
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Temp\Projectgegevens.txt", ConfirmConversions:=False, ReadOnly:=False _
, LinkToSource:=True, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", WritePasswordDocument:="", WritePasswordTemplate:= _
"", Revert:=False, Format:=wdOpenFormatAuto, Connection:="", SQLStatement _
:="", SQLStatement1:=""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
einde:
End Sub
I'm trying to use a word document as input for project specific information. This information is needed in multiple other Word documents so I am using the Mailmerge function. After you have filled in the word document you'll have to choose the language of the Word documents.I am making this with a document someone else already built. I am getting problems when changing the input fields and declarations of them.
This is my code so far:
Sub Projectplan()
ActiveDocument.SaveAs FileName:="C:\temp\Projectgegevens.txt", FileFormat:= _
wdFormatText, LockComments:=False, Password:="", AddToRecentFiles:= _
False, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=True, _
SaveAsAOCELetter:=False
Application.DisplayStatusBar = True
With ActiveDocument
.ReadOnlyRecommended = False
.EmbedTrueTypeFonts = False
.SaveFormsData = False
.SaveSubsetFonts = False
.Password = ""
.WritePassword = ""
End With
Dim opmdat As String
WordBasic.FileOpen Name:="C:\temp\Projectgegevens.txt"
WordBasic.Insert opmdat + Chr(10)
WordBasic.FileSave
WordBasic.FileClose 1
Keuzescherm.Show
End Sub
Sub Samenvoegen()
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Temp\Projectgegevens.txt", ConfirmConversions:=False, ReadOnly:=False _
, LinkToSource:=True, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", WritePasswordDocument:="", WritePasswordTemplate:= _
"", Revert:=False, Format:=wdOpenFormatAuto, Connection:="", SQLStatement _
:="", SQLStatement1:=""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
einde:
End Sub