A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Losing textbox on table



 
 
Thread Tools Display Modes
  #11  
Old November 19th, 2006, 12:00 AM posted to microsoft.public.word.tables
Jack
external usenet poster
 
Posts: 9
Default Losing textbox on table

Thanks for the very interesting alternative approach. I am still trying to
digest it. I have several questions I am not clear on
1)In step 2 you create a "Sub Table" that contains both the prev and next
months data"(Pretty clever). Does this appear in a seaprte space on the
page or did you place this within the main calendar table?
2)You store the days for each month in an array. What is the code to place
the contents of the array into a selection of cells in the table?
Thanks Jack

"macropod" wrote in message
...
Hi Jack,

An alternative approach, which I think would be easier to implement, would
be to:
. create a 'main' table for the current month. This table would have a top
row that spans the full width of the table and will hold the month name.
Below that you'd have another 5 rows, each being 7 columns across, for the
days/dates.
. insert a 'sub' table, above or below the 'main' table on the same page,
to
hold the preceding & following month data, plus space between. This table
would thus have a top row that is nominally three columns wide, with the
preceding & following month names in the outer columns. The middle column
might be empty. Below that you'd have another 5 rows, each being 15
columns
across. The middle column on these rows would be the same width as for the
middle column on the top row.
. format the tables for a generic page.
. make a total of 13 copies of this page.
. create and populate three 5*7 arrays - 'lastmonth', 'thismonth',
'nextmonth' - to hold the day & date info for (last) December, January and
February.
. go to the first page
. insert the 'thismonth' calendar in the main table, followed by the
'lastmonth' calendar in the left of the 'sub' table, then the 'nextmonth'
calendar in the right of the 'sub' table.
. move the data from 'thismonth' to 'lastmonth' and from 'nextmonth' to
'thismonth'.
. create a new 'nextmonth', where 'nextmonth' = 'thismonth'+1.
. repeat the last 3 steps on the next page, and continue until all pages
have been processed.

As you can see, there is no need to use either text boxes or copy/paste
operations. Properly implemented, there's also no need for any
selections -
you can use ranges instead, which will make the code execute more quickly.

Cheers

--
macropod
[MVP - Microsoft Word]


"Jack" wrote in message
. ..
Thanks for the response.
I have checked out your Microsoft link and the only one that comes close

to
my problem is the one that talks about hyperlinks. But still a mystery.
Looking at my code do you see another technique to accomplish what I am
after? I am thinking of just creating the textboxes by hand, use the
routine to fill each with the proper days and then manually drag them to

the
appropriate tables.
Jack
"macropod" wrote in message
...
Hi Jack,

I'm unable to reproduce the error with your code. I use Word 2000.

Perhaps
you should check he

http://search.support.microsoft.com/...ry=41 98&adv=
and see if any of those issues/fixes apply.

Cheers

--
macropod
[MVP - Microsoft Word]


"Jack" wrote in message
. ..
Thanks for responding. Let me be more specific what I am trying to do
I am basically making a 13 month calendar. In the document there is
13
pages each page contains a table( a little smaller than the size of
the
page) for the main month. I have code that generates the days of the
month
for each page and that all works correctly.

Now what I need is to create for each main month two small submonths

that
represent the previous and next months like you see in many calendars.
These two "small months" will be placed in one of the cells of the

month.

The way I do it is that I have created a shape which is just a text
box
that
is sized to fit in one of the cells of the "big month"(table on a

page).
Within this small textbox I have a table whose cells contains the days

of
the month. I have code that fills the table within the textbox with

days
of
the month for any given month and year.

So after I create a given main month, I use the single textbox, fill

with
the previous month's data, copy it and paste it into the main month
table.
I then generate another for the Next month and past it into the big
month.

I repeat this process for all the months of the calendar.
I hope this clarifies whatI am trying to do. I have inclued the code
from
the main routine. Wehn i=1, ti goes through the whole process

correctly
and
pstes the two submonths onto the table(although not in the correct
position)(which I can easily just move them later). The error occurs
when
i=2 .when it tries to paste the first of the submonths. the error is
4198

thanks for any help.
Jack


Here is the code for the main routine
Public Sub MainControl()
Dim iYear, iMonth, iCalendarYear, iSubMonth As Integer
Dim dt As Date
Dim shp As Shape
Dim tbl As Table
Dim rng As Range
iCalendarYear = 2006 'This would normaly come from an input
For i = 1 To 13 'will be 1 to 13
If i = 13 Then
iMonth = 1
iYear = iCalendarYear + 1
Else
iMonth = i
iYear = iCalendarYear
End If
dt = DateSerial(iYear, iMonth, 1)

'Create month calendar
Set tbl = ActiveDocument.Tables(i)
Set rng = tbl.Range.Cells(8).Range
Call CreateMonth(dt, tbl)
'Create subCalendars
Set shp = ActiveDocument.Shapes("submonth")
Set tbl = shp.TextFrame.TextRange.Tables(1)
'Create Previous month
If iMonth - 1 0 Then
dt = DateSerial(iYear - 1, 12, 1)
Else
dt = DateSerial(iYear, iMonth - 1, 1)
End If
Call CreateSubMonths(dt, tbl)
'Paste shape into calendar table rnage
shp.Select
Selection.Copy
rng.Paste

'Create next month
Set shp = ActiveDocument.Shapes("submonth")
Set tbl = shp.TextFrame.TextRange.Tables(1)
If iMonth + 1 12 Then
dt = DateSerial(iYear + 1, 1, 1)
Else
dt = DateSerial(iYear, iMonth + 1, 1)
End If
Call CreateSubMonths(dt, tbl)
shp.Select
Selection.Copy
rng.Paste
Next i
End Sub

"macropod" wrote in message
...
Hi Jack,

I'm not quite sure what you're trying to do here, but it looks as
though
you're trying to capture the user's input into a text box and

transfer
that
to particular table cells. The code you posted, though, seems to

simply
create additional text boxes instead.

If you're trying to capture the user's input and transfer that to
particular
table cells, try something like the following:

Sub Table_Input()
Dim i As Integer
Dim str As String
For i = 1 To ActiveDocument.Tables.Count
With ActiveDocument.Tables(i).Cell(2, 2)
str = Left(.Range.Text, Len(.Range.Text) - 2)
.Range.Delete
.Range.Text = InputBox("Text to input in table " & i, , str)
End With
Next i
End Sub

The above code cycles through all tables in the document, clearing

the
contents of cell B2 and soliciting a new text string with the

original
text
as the default. The user can then clear, edit/replace or add to the
former
string. If you need to have the last table's update reflected in a

text
box,
the code for that could be added to the macro.

An even simpler way to update the tables would be to insert text
formfields
into the appropriate cells, and protect the document for forms. The
document
wouldn't automatically solicit input for each formfield, though that
could
be driven from code, but the user wouldn't be restricted to updating

a
few
cells by running a macro that cycles though all tables.

If this isn't helpful, on which line of code were you getting the

error
4198? Some more of your code for context would help too.

Cheers
PS: Typo in your posted code - 'tbl' is defined 'set
tbl=activedocument.tables(i)', but 'tlb' is used 'set
rng=tlb.range.cells(2).range'.

--
macropod
[MVP - Microsoft Word]


"Jack" wrote in message
. ..
I see you have the mvp credentials. I have another question that
relates
to
my previous one that yu may have some insight. I have several(like
13)
tables and a separte textbox that is rectangular which is located
on
the
last page of the document.. What i want to do is change the text
in
the
box, copy that textbox and paste a copy in one of the table cells
using
VBA
code. I would repeat this for each of the tables.
That would help solve my manual placing it there. The reason for
doing
it
in code I have a number of these to place

I have tried code like:

set tbl=activedocument.tables(i)
set shp=activedocument.shapes("TemplateBox")
'Change text in box
shp.textframe.textrange.text="bbbbbb"or whatever
shp.select
selection.copy
set rng=tlb.range.cells(2).range
rng.paste


that works on the first table(although it in not quite in the
proper
cell..but I can move it around). But when I do it on a subsequent
table,
I
get an error 4198
If you can guide me on this, I wont worry about my orginal question
Thanks
Jack


"macropod" wrote in message
...
Hi Jack,

It could still be a display driver problem. Have you checked for
later
'release' drivers (i.e. not betas) for your video card?

Also, try going into the control panel and reducing the amount of
hardware
acceleration.

Cheers

--
macropod
[MVP - Microsoft Word]


"Jack" wrote in message
. ..
I tried that and it didnt make any difference
Jack
"macropod" wrote in message
...
Hi Jack,

Could be a display driver problem. Have you tried scrolling
up/down
to
an
area that doesn't show either the table or text box, then back
again,
after
moving the text box? Does that have any effect?

Cheers

--
macropod
[MVP - Microsoft Word]


"Jack" wrote in message
. ..
I have a text box on a page that has a table. The text box
is
above
the
table. When I drag the text box to place into a cell in the
table,
it
disappears. The strange thing is that when I drag it so part

is
off
the
table and some is on it, all of the text box displays ok.
However,
dragging
further in it disappears.
I am not sure what is happening. I have other text boxes
that
can
be
dragged into other cells and they work ok. I have the layout
set
to
"In
front of text"
Jack






















  #12  
Old November 19th, 2006, 01:03 AM posted to microsoft.public.word.tables
macropod
external usenet poster
 
Posts: 1,231
Default Losing textbox on table

Hi Jack,
1)In step 2 you create a "Sub Table" that contains both the prev and next
months data"(Pretty clever). Does this appear in a seaprte space on the
page or did you place this within the main calendar table?

I'd be inclined to put it on the page as a separate table. All this implies
is that there'll be at least one paragraph mark separating the 'main' and
'sub' tables. If the tables are the same overall width, you could delete the
intervening paragraph mark(s) to join the tables afterwards.

2)You store the days for each month in an array. What is the code to

place
the contents of the array into a selection of cells in the table?


Somehting like:
Option Explicit

Sub TestTable()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim ThisMonth(5, 7)
For j = 1 To 7
For k = 1 To 5
ThisMonth(k, j) = 5 * (j - 1) + k
Next
Next
With ActiveDocument.Tables(1)
For j = 1 To 7
.Cell(1, j).Range.Text = ThisMonth(1, j)
.Cell(2, j).Range.Text = ThisMonth(2, j)
.Cell(3, j).Range.Text = ThisMonth(3, j)
.Cell(4, j).Range.Text = ThisMonth(4, j)
.Cell(5, j).Range.Text = ThisMonth(5, j)
Next
End With
End Sub
No need for a Selection as such - simply specify the table.

Cheers

--
macropod
[MVP - Microsoft Word]


  #13  
Old November 20th, 2006, 09:16 PM posted to microsoft.public.word.tables
Jack
external usenet poster
 
Posts: 9
Default Losing textbox on table

Thanks macropod. I will try this code. I have worked with arrays and so I
follow what you did. I still would have liked to get the submonths table
into the actual month calendar in one of the cells. But this is a great
alternative
Thanks for all your help
Jack
"macropod" wrote in message
...
Hi Jack,
1)In step 2 you create a "Sub Table" that contains both the prev and next
months data"(Pretty clever). Does this appear in a seaprte space on the
page or did you place this within the main calendar table?

I'd be inclined to put it on the page as a separate table. All this
implies
is that there'll be at least one paragraph mark separating the 'main' and
'sub' tables. If the tables are the same overall width, you could delete
the
intervening paragraph mark(s) to join the tables afterwards.

2)You store the days for each month in an array. What is the code to

place
the contents of the array into a selection of cells in the table?


Somehting like:
Option Explicit

Sub TestTable()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim ThisMonth(5, 7)
For j = 1 To 7
For k = 1 To 5
ThisMonth(k, j) = 5 * (j - 1) + k
Next
Next
With ActiveDocument.Tables(1)
For j = 1 To 7
.Cell(1, j).Range.Text = ThisMonth(1, j)
.Cell(2, j).Range.Text = ThisMonth(2, j)
.Cell(3, j).Range.Text = ThisMonth(3, j)
.Cell(4, j).Range.Text = ThisMonth(4, j)
.Cell(5, j).Range.Text = ThisMonth(5, j)
Next
End With
End Sub
No need for a Selection as such - simply specify the table.

Cheers

--
macropod
[MVP - Microsoft Word]




  #14  
Old November 21st, 2006, 04:09 AM posted to microsoft.public.word.tables
macropod
external usenet poster
 
Posts: 1,231
Default Losing textbox on table

hi Jack,

I still would have liked to get the submonths table
into the actual month calendar in one of the cells.


You can still do that, provided you either split that cell into a
multi-column/row matrix or use table & line feeds to control the layout.
Splitting a cell into a multi-column/row matrix and inputting the values
into that isn't much different to using another table.

--
macropod
[MVP - Microsoft Word]


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.