BONSOIR
j'ai un petit souci d'exportation vers word aussi
j'ai recopié le code suivant
et cela ne marche pas ( le fichier word que j'ai crée s'ouvre bien mais les variables de mon formulaire ne s'affichent pas il y à juste la date mais c'est logique ce n'est pas une variable envoyée;
je n'arrive pas à les déclarer et le scenario proposé dans le code addylinevar ne marche pas et c'est trop compliqué je voudrais un truc simple style:
déclarer la variable de mon formulaire : interlocuteur
et l'envoyer dans le signet interlocuteur de mon doc word
pouvez vous m'aider de vos lumieres
merci
gk
Private Sub MergeBttn_Click()
Declare variables for storing strings (text).
Dim AddyLineVar, SalutationVar As String
Start building AddyLineVar, by dealing with blank
LastName and Company fields (allowed in this table).
If IsNull([Raison_sociale]) Then
AddyLineVar = [Interlocuteur]
'Just set SalutationVar to generic "Sirs".
'SalutationVar = "Sirs"
Else
' AddyLineVar = [CP] + " " + [Raison_sociale]
If the Company isn't blank, tack that on after name.
' If Not IsNull([Interlocuteur]) Then
' AddyLineVar = AddyLineVar + vbCrLf + [VILLE]
End If
Salutation will be customer's first name.
SalutationVar = [sirs]
End If
'Add line break and Address1
AddyLineVar = AddyLineVar + vbCrLf + [Addresse]
If Address2 isn't null, add line break and Address2
If Not IsNull([Address2]) Then
AddyLineVar = AddyLineVar + vbCrLf + [Address2]
End If
Tack on line break then City, State Zip.
AddyLineVar = AddyLineVar + vbCrLf + [REGION] + ", "
AddyLineVar = AddyLineVar + [activité] + " " + [Imprimantes]
'Declare an instance of Microsoft Word.
Dim Wrd As New word.Application
Set Wrd = CreateObject("Word.Application")
'Specify the path and name to the Word document.
Dim MergeDoc As String
MergeDoc = Application.CurrentProject.Path
MergeDoc = MergeDoc + "\WordFormLetter.dot"
'Open the document template, make it visible.
Wrd.Documents.Add MergeDoc
Wrd.Visible = True
'Replace each bookmark with current data.
With Wrd.ActiveDocument.Bookmarks
.Item("TodaysDate").Range.Text = Date
Item("bloc adresse").Range.Text = "adresse"
.Item("Salutation").Range.Text = SalutationVar
End With
'Letter is ready to print, so print it.
'Wrd.ActiveDocument.PrintOut
'All done. Close up (no need to save document)
'Wrd.ActiveDocument.Close wdDoNotSaveChanges
Wrd.Quit