Piloter l'automation de Word avec C#
Bonjour,
J'essaye en vain de traduire une application qui formate en automation sous word des étiquettes.
Je reste bloqué avec la création d'un nouveau template de label.
Voici mon code actuel en C#
Code:
1 2 3 4 5 6 7 8 9 10 11
|
Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
var document = new Microsoft.Office.Interop.Word.Document();
var oFields = document.MailMerge.Fields ;
oFields.Application.Selection.Font.Name = "Times New Roman";
oFields.Application.Selection.Font.Size = 8;
oFields.Application.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
oFields.Add(application.Selection.Range, "Description");
application.Selection.TypeParagraph(); |
J'essaye en vain de traduire les commandes suivantes (VB6) en C#
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
Dim oAutoText As Word.AutoTextEntry
Set oAutoText = objWord.NormalTemplate.AutoTextEntries.Add("MyLabelLayout", objDocument.Content)
objDocument.Content.Delete
.MainDocumentType = wdMailingLabels
.OpenDataSource Name:=App.Path & "\PrintStickers.xlsx", SQLStatement:="SELECT * FROM [Sheet1$]"
objWord.MailingLabel.CreateNewDocument Name:="L7651", Address:="", _
AutoText:="MyLabelLayout", LaserTray:=wdPrinterManualFeed
.Destination = wdSendToNewDocument
.Execute
oAutoText.Delete |
Dans l'automation de word l'objet Word.AutoTextEntry mais je ne trouve aucune information quand à la manière de l'utiliser.
Aparement ca n'existe qu'en Interface http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx.
J'ai bien trouvé ceci : http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx mais je n'arrive pas à en extraire ce que je désire.
Si quelqu'un a déjà travailler avec cela...
Merci d'avance.