G
Guest
Hey all
I generate a word document from an access script. I generate a new table
inside the new document. I preset the table with a specified number of
columns and rows (using variables from a form input) and then merge all
columns in the first two rows for headers I write there. Because of the
merging, it will not allow me to specify preferred column widths. A message
comes up stating that it cannot isolate those columns because there are cells
of different widths. Here's my code:
Set tblNew = docActive.Tables.Add( _
Range:=docActive.Range(Start:=0, End:=0), NumRows:=totalrows,
NumColumns:=totalcols)
intCount = 1
tblNew.Borders.OutsideLineStyle = wdLineStyleSingle
tblNew.Borders.InsideLineStyle = wdLineStyleSingle
docActive.Range(tblNew.Cell(1, 1).Range.Start, tblNew.Cell(1,
totalcols).Range.End).Cells.Merge
tblNew.Cell(1, 1).Range.InsertAfter Header
tblNew.Cell(1, 1).Range.Font.Name = "Helvetica"
tblNew.Cell(1, 1).Range.Font.Bold = True
tblNew.Cell(1, 1).Range.Font.Size = 18
tblNew.Cell(1, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
docActive.Range(tblNew.Cell(2, 1).Range.Start, tblNew.Cell(2,
totalcols).Range.End).Cells.Merge
tblNew.Cell(2, 1).Range.InsertAfter Subhead
tblNew.Cell(2, 1).Range.Font.Name = "Helvetica"
tblNew.Cell(2, 1).Range.Font.Bold = True
tblNew.Cell(2, 1).Range.Font.Size = 16
tblNew.Cell(2, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
tblNew.Cell(3, 1).Range.InsertAfter "Rank"
tblNew.Cell(3, 1).Range.Font.Name = "Helvetica"
tblNew.Cell(3, 1).Range.Font.Bold = True
tblNew.Cell(3, 1).Range.Font.Size = 7
tblNew.Cell(3, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
tblNew.Cell(3, 1).Range.Cells.VerticalAlignment = wdCellAlignVerticalBottom
tblNew.Cell(3, 1).Range.Borders(wdBorderRight).LineStyle = wdLineStyleNone
At this point I attempt to at least set preferred cell widths for these
cells - the first cell I set at .65 inches, the second at 2. As soon as the
second cell, 2nd column on 3rd row is written at 2 inches, the whole table
goes off the right margin because it auto sets all other cells (the contents
of which have not yet been written to it) at .95 inches as a default. So then
I tried setting column widths, but then I got the message described earlier.
So I set NO widths at all, and my page setup and margins are kept intact, but
the user then has to manually set the column widths in word.
Any ideas? I know this explanation probably sucks, but my brain is shutting
down.
Thanks for any help.
I generate a word document from an access script. I generate a new table
inside the new document. I preset the table with a specified number of
columns and rows (using variables from a form input) and then merge all
columns in the first two rows for headers I write there. Because of the
merging, it will not allow me to specify preferred column widths. A message
comes up stating that it cannot isolate those columns because there are cells
of different widths. Here's my code:
Set tblNew = docActive.Tables.Add( _
Range:=docActive.Range(Start:=0, End:=0), NumRows:=totalrows,
NumColumns:=totalcols)
intCount = 1
tblNew.Borders.OutsideLineStyle = wdLineStyleSingle
tblNew.Borders.InsideLineStyle = wdLineStyleSingle
docActive.Range(tblNew.Cell(1, 1).Range.Start, tblNew.Cell(1,
totalcols).Range.End).Cells.Merge
tblNew.Cell(1, 1).Range.InsertAfter Header
tblNew.Cell(1, 1).Range.Font.Name = "Helvetica"
tblNew.Cell(1, 1).Range.Font.Bold = True
tblNew.Cell(1, 1).Range.Font.Size = 18
tblNew.Cell(1, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
docActive.Range(tblNew.Cell(2, 1).Range.Start, tblNew.Cell(2,
totalcols).Range.End).Cells.Merge
tblNew.Cell(2, 1).Range.InsertAfter Subhead
tblNew.Cell(2, 1).Range.Font.Name = "Helvetica"
tblNew.Cell(2, 1).Range.Font.Bold = True
tblNew.Cell(2, 1).Range.Font.Size = 16
tblNew.Cell(2, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
tblNew.Cell(3, 1).Range.InsertAfter "Rank"
tblNew.Cell(3, 1).Range.Font.Name = "Helvetica"
tblNew.Cell(3, 1).Range.Font.Bold = True
tblNew.Cell(3, 1).Range.Font.Size = 7
tblNew.Cell(3, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
tblNew.Cell(3, 1).Range.Cells.VerticalAlignment = wdCellAlignVerticalBottom
tblNew.Cell(3, 1).Range.Borders(wdBorderRight).LineStyle = wdLineStyleNone
At this point I attempt to at least set preferred cell widths for these
cells - the first cell I set at .65 inches, the second at 2. As soon as the
second cell, 2nd column on 3rd row is written at 2 inches, the whole table
goes off the right margin because it auto sets all other cells (the contents
of which have not yet been written to it) at .95 inches as a default. So then
I tried setting column widths, but then I got the message described earlier.
So I set NO widths at all, and my page setup and margins are kept intact, but
the user then has to manually set the column widths in word.
Any ideas? I know this explanation probably sucks, but my brain is shutting
down.
Thanks for any help.