neo1602brice
Messages postés77Date d'inscriptiondimanche 27 avril 2003StatutMembreDernière intervention10 juillet 2009
-
30 mai 2008 à 12:14
neo1602brice
Messages postés77Date d'inscriptiondimanche 27 avril 2003StatutMembreDernière intervention10 juillet 2009
-
31 mai 2008 à 00:46
Salut à tous c'est encore moi
Je tiens d'abord à remercier encore bigfish_le vrai pour son aide(voir ici) mais lorsque je lance mon programme il m'affiche l'erreur suivante
"Erreur d'exécution 91: Variable d'objet ou bloc with non défini"
Voici mes procédures:
Private Sub Command1_Click()
Call CreeTableau(5, 2)
End Sub
Public Sub CreeTableau(NbLignes As Integer, NbColonnes As Integer)
Dim wd As Word.Application
Set wd = CreateObject("word.application")
With wd
.Documents.Add
.Visible = True
.ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=NbLignes, NumColumns:=NbColonnes
End With
End Sub
Il me fait donc mon erreur sur la ligne en rouge !!!!
Je suis perdu
bigfish_le vrai
Messages postés1835Date d'inscriptionvendredi 13 mai 2005StatutMembreDernière intervention20 novembre 201315 30 mai 2008 à 17:01
Salut,
merci pour les remerciments
je te donne 2 methodes, a toi de voir, mais j'ai pas d'explication j'ai juste utilisé l'aide
Sub CreeTableau(NbLignes As Long, NbColonnes As Long)
Dim wd As Object, myRange As Object
Set wd = CreateObject("word.application")
With wd
.Documents.Add
.Visible = True
Set myRange = .ActiveDocument.Range(0, 0)
.ActiveDocument.Tables.Add Range:=myRange, NumRows:=NbLignes, NumColumns:=NbColonnes
End With
End Sub
Sub CreeTableau(NbLignes As Long, NbColonnes As Long)
Dim wd As Object, myTable As Object, myRange As Object
Set wd = CreateObject("word.application")
With wd
.Documents.Add
.Visible = True
Set myRange = .ActiveDocument.Range(0, 0)
Set myTable = .ActiveDocument.Tables.Add(Range:=myRange, NumRows:=NbLignes, NumColumns:=NbColonnes)
End With
End Sub
et j'aime toujours pas word
remarque : essai d'etre le plus generale possible c'est a dire de declare la variable wd en object et pas en Word.Application et aussi de ne pas utilisé de format predefinit specifique a word ou tout autre specificité. cela permetra a ton projet d'etre facilement exportable sans avoir a utilisé la reference microsoft word.
y a rien a faire j'aime pas word
et puis tien je vais etre gentil voici un bout de l'aide :
------------------------------------------------------------------------------------------------------------------
This example adds a blank table with three rows and four columns at the
beginning of the active document.
This example adds a table with three rows and five columns to a new document
and then inserts data into each cell in the table.
Sub NewTable()
Dim docNew As Document
Dim tblNew As Table
Dim intX As Integer
Dim intY As Integer
Set docNew = Documents.Add
Set tblNew = docNew.Tables.Add(Selection.Range, 3, 5)
With tblNew
For intX = 1 To 3
For intY = 1 To 5
.Cell(intX, intY).Range.InsertAfter "Cell: R" & intX & ", C" & intY
Next intY
Next intX
.Columns.AutoFit
End With
End Sub
-----------------------------------------------------------------------------------------