Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
knight06 knight06 is offline
external usenet poster
 
Posts: 2
Default Programatically assigning values to table cells

Hello guys:
I have table on a one-page doc that's designed to fit with a label sheet (4
by 10), I want to programatically assign a sequence of numbers with
repeatition to the cells in this manner:
1 1 2 2
3 3 4 4
....................
20 20 21 21

I have this code I got from utteraccess forum, but it was for excel, and am
not sure if works with word. I made a button and added the code but it asked
me to enable macros!
Here is the code:
Private Sub CommandButton1_Click()
Dim i As Integer
Dim k As Integer

ActiveSheet.Range("A1").Select
k = 1

For i = 1 To 1000
ActiveCell.Offset(k - 1, 0).Value = i
ActiveCell.Offset(k - 1, 1).Value = i
i = i + 1
k = k + 1
ActiveCell.Offset(k - 2, 2).Value = i
ActiveCell.Offset(k - 2, 3).Value = i

Next i

End Sub
Thank you very much.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Robert M. Franz (RMF) Robert M. Franz (RMF) is offline
external usenet poster
 
Posts: 1,741
Default Programatically assigning values to table cells

knight06 wrote:
Hello guys:
I have table on a one-page doc that's designed to fit with a label sheet (4
by 10), I want to programatically assign a sequence of numbers with
repeatition to the cells in this manner:
1 1 2 2
3 3 4 4
...................
20 20 21 21

I have this code I got from utteraccess forum, but it was for excel, and am
not sure if works with word. [code snipped]


it will certainly not work, as it's dealing with Excel objects
(worksheet etc.), in Word.

Personally, I would use two different SEQ fields (one simply counting
upwards, the other always repeating the last member of the sequence) for
that (it's certainly the easiest way to do that manually, and might be
an idea for tackling this programmatically, too.

If you really do need code, best ask about that in one of the .word.vba
forums.

HTH
Robert
--
/"\ ASCII Ribbon Campaign | MS
\ / | MVP
X Against HTML | for
/ \ in e-mail & news | Word
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
knight06 knight06 is offline
external usenet poster
 
Posts: 2
Default Programatically assigning values to table cells

Thanx Robert, and I appreciate your advice.

"Robert M. Franz (RMF)" wrote:

knight06 wrote:
Hello guys:
I have table on a one-page doc that's designed to fit with a label sheet (4
by 10), I want to programatically assign a sequence of numbers with
repeatition to the cells in this manner:
1 1 2 2
3 3 4 4
...................
20 20 21 21

I have this code I got from utteraccess forum, but it was for excel, and am
not sure if works with word. [code snipped]


it will certainly not work, as it's dealing with Excel objects
(worksheet etc.), in Word.

Personally, I would use two different SEQ fields (one simply counting
upwards, the other always repeating the last member of the sequence) for
that (it's certainly the easiest way to do that manually, and might be
an idea for tackling this programmatically, too.

If you really do need code, best ask about that in one of the .word.vba
forums.

HTH
Robert
--
/"\ ASCII Ribbon Campaign | MS
\ / | MVP
X Against HTML | for
/ \ in e-mail & news | Word

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table Format Style vs. Table Text Style WebColin Page Layout 11 December 1st 05 11:29 PM
Select specific cells in table via macro Bill Sturdevant Microsoft Word Help 1 July 27th 05 03:01 PM
Table headers/footers and layout Keith Page Layout 1 April 8th 05 07:37 PM
Table AutoFormats vs. Table Styles confusion Tony Jollans Tables 5 March 6th 05 07:18 PM
Automatic calculation as data is entered into table cells Gerry Duggan Microsoft Word Help 1 February 23rd 05 10:57 PM


All times are GMT +1. The time now is 05:19 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"