Using Excel VBA Get the "Page Number" of Table current cells in Winword.

justuptou

New Member
Joined
Jan 8, 2020
Messages
23
Office Version
  1. 2010
Platform
  1. Windows
Dear all,

I am using the Excel Table to store some records, then using VBA copy the a lot of data to winword table and generate the report. ( see attached )

My Pseudo code by Excel VBA coding
Copy Excel to Data Array
Open Winword.application
Create a table in winword
then Put the Data Array into the winword
(I want to do something when there is different page)
(so, How can I coding when I copy data to winword that I know the page number ( for example there is in Page 1 or 2 ))

Rename and Saved the file
Close Winword.application

I have tried to set the value / show it in msgbox as below coding.
MsgBox objDoc.tables(1).Cell(1, 1).Range.Information(wdActiveEndPageNumber)
' Report the existing cell (try the First cell) which page is located but failed as 'Run-time error 4608 / Value out of range'
1578536080463.png
 

Attachments

  • ExceltoWinword_ReportPageNo.png
    ExceltoWinword_ReportPageNo.png
    75.9 KB · Views: 6

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Please review the forum guidelines re. cross posting at both this site and vbaexpress.com Dave
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,692
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top