Forum Discussion
Help with Paste from excel to word
- Sep 22, 2022
Tommaso_Bertocchi I apologize in advance if this makes you cry.
Using Visual Basic in Word, you can add a table to a document using a command such as
The table will be added to the Range, which can be defined in a number of ways. For example if the table was to be added at the end of the document, you would use
Dim NewTable As Table
Dim tblRange As Range
Set tblRange = ActiveDocument.Range
tblRange. Collapse wdCollapseEnd
Set NewTable = ActiveDocument.Tables.Add(tblRange, NumRows, NumColumns, etc)
While you would usually set the tolal number of columns when adding the table, in most cases you would not set the total number of rows as you can simply use
NewTable.Rows.Add
whenever a new row is required.
The following is a listing of the members of the Table class
As an example, this is a screen shot of onw of the tables in an 1100 page document that was created, populated with text and formatted using a visual basic routine run from an Access database
with excel i can easily define ranges/cells, and then choose where and how to insert data/text/pictures
you telling me i can do the same on word? lets say i have something like this..
here some text already written in word
here i want to build/insert a table with energy comsumption or whatever data
here some more text already written in the document
is it possible to actually make a macro that create the table in the right place??
if the answer is yes i will cry because i invested so many hours in excelt thinking it was not possible to do so.....
(another big question is.. how can word knows where to find the files? on excel is easy because i literally link (trough macro) the files, so the user doesnt have to manually write any filepath or whatever)
Tommaso_Bertocchi I apologize in advance if this makes you cry.
Using Visual Basic in Word, you can add a table to a document using a command such as
The table will be added to the Range, which can be defined in a number of ways. For example if the table was to be added at the end of the document, you would use
Dim NewTable As Table
Dim tblRange As Range
Set tblRange = ActiveDocument.Range
tblRange. Collapse wdCollapseEnd
Set NewTable = ActiveDocument.Tables.Add(tblRange, NumRows, NumColumns, etc)
While you would usually set the tolal number of columns when adding the table, in most cases you would not set the total number of rows as you can simply use
NewTable.Rows.Add
whenever a new row is required.
The following is a listing of the members of the Table class
As an example, this is a screen shot of onw of the tables in an 1100 page document that was created, populated with text and formatted using a visual basic routine run from an Access database
- Tommaso_BertocchiSep 22, 2022Copper Contributori will further investigate and learn, i really appreciate your help sir!
anyway we didnt discover why the hell it paste in a wrong way on word2016 but works fine on word2010! not a big deal, i will find a work-around