Creation Doc sous VB: Comment savoir si on est en fin de page ?
cs_Hobby
Messages postés116Date d'inscriptionmercredi 5 juin 2002StatutMembreDernière intervention17 septembre 2008
-
18 nov. 2002 à 04:52
cs_Hobby
Messages postés116Date d'inscriptionmercredi 5 juin 2002StatutMembreDernière intervention17 septembre 2008
-
19 nov. 2002 à 04:54
Bonjour,
J'ai quelques problêmes de creation de document Word avec VB surtout contenant des Tableaux:
Le problème est en général au changement de page. Il y a t'il un moyen de savoir la posistion du curseur ?
Un Exemple si je cree un tableau en fin de page est que je fait un MoveDown pour sortir du tableau, j'ai une erreur "propriété MoveDown..." J'ai résoltut le probleme en rendans visible Word. Mais plus loin je suis tombé sur un autre problème je cree un tableau en fin de page qui est a cheval sur la page suivante et la le Movedown ne passe pas a page suivante se qui a pour effet une mise en page incorect les tableaux suivant s'imbrique les uns dans les autres.
Une solution ?
Merci
Olivier
Ps: Voici le code:
Dans un bouton command1()
Public wrdApp As New Word.Application
Public wrdDoc As New Word.Document
Public Sub NouveauDoc()
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
wrdDoc.Content.LanguageID = wdBelgianFrench
wrdDoc.Content.NoProofing = False
wrdDoc.PageSetup.TopMargin = CentimetersToPoints(1)
wrdDoc.PageSetup.LeftMargin = CentimetersToPoints(1)
wrdDoc.PageSetup.BottomMargin = CentimetersToPoints(1)
wrdDoc.PageSetup.RightMargin = CentimetersToPoints(1)
End Sub
Public Sub NouvelleTable(Ligne As Integer, Colone As Integer)
wrdDoc.Tables.Add Range:=Selection.Range, numrows:=Ligne, NumColumns:=Colone, _
DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
End Sub
Public Sub NouvelleTableStd(Ligne As Integer)
wrdDoc.Tables.Add Range:=Selection.Range, numrows:=Ligne, NumColumns:=3, _
DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
Call TailleColone(1, 100)
Call TailleColone(2, 80)
Call TailleColone(3, 366)
End Sub
Public Sub DeplacementBas(Nombre As Integer)
Selection.MoveDown Unit:=wdLine, Count:=Nombre
End Sub
Public Sub DeplacementDroite(Nombre As Integer)
Selection.MoveRight Unit:=wdCharacter, Count:=Nombre
End Sub
Public Sub ToucheEnter(Nombre As Integer)
Dim intA
For intA = 1 To Nombre
Selection.TypeParagraph
Next intA
End Sub
Public Sub TextCellule(Ligne As Integer, Colone As Integer, Texte As String)
Selection.Tables(1).Cell(Row:=Ligne, Column:=Colone).Range.InsertBefore Text:=Texte
End Sub
Public Sub TailleColone(Colone As Integer, Taille As Integer)
Selection.Tables(1).Columns(Colone).SetWidth ColumnWidth:=Taille, RulerStyle:=wdAdjustNone
End Sub
Public Sub AddTexteGras(Texte As String)
Selection.Font.Bold = wdToggle
Selection.TypeText Text:=Texte
Selection.Font.Bold = wdToggle
End Sub
Public Sub AddTexte(Texte As String)
Selection.TypeText Text:=Texte
End Sub
Public Sub AddTexteGris(Texte As String)
Dim intA
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
If Selection.Font.Bold = 0 Then
Selection.Font.Bold = wdToggle
End If
Selection.TypeText Text:=Texte
intA = Len(Texte)
Selection.MoveLeft Unit:=wdCharacter, Count:=intA, Extend:=wdExtend
Options.DefaultHighlightColorIndex = wdGray25
Selection.Range.HighlightColorIndex = wdGray25
Call DeplacementBas(1)
Options.DefaultHighlightColorIndex = wdNoHighlight
Selection.Range.HighlightColorIndex = wdNoHighlight
Selection.Font.Bold = wdToggle
Call ToucheEnter(2)
End Sub
Public Sub SousTitre(Texte As String)
Call NouvelleTable(1, 1)
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Selection.Font.Bold = wdToggle
Selection.TypeText Text:=Texte
Call DeplacementBas(1)
Call ToucheEnter(1)
End Sub
A voir également:
Creation Doc sous VB: Comment savoir si on est en fin de page ?
cs_Hobby
Messages postés116Date d'inscriptionmercredi 5 juin 2002StatutMembreDernière intervention17 septembre 2008 19 nov. 2002 à 04:54
Plutot que de faire ceci:
Public Sub DeplacementBas(Nombre As Integer)
Selection.MoveDown Unit:=wdLine, Count:=Nombre
End Sub
Faire cela
Public Sub DeplacementBas(Nombre As Integer)
Din intA
For intA = 1 to Nombre
Selection.MoveDown Unit:=wdLine, Count:=1
Next intA
End Sub
Cela fonctionne un peut mieux, mais le probleme de fin de page persiste puisque vous devez ajouter un deplacement supplementaire pour le changement de page.