How Do I Script Tables and make page breaks form a html Page 
Author Message
 How Do I Script Tables and make page breaks form a html Page

I have a html page I am using for an interface to a script , It makes
a formated Word document, everything is typed on it fine , but now I
want to
add pagebreak for the second page and a table  help

the code

 Sub frmSubmit_onclick()  

 '     XXXXXXXXx          
 '     Initialize varables  
 '     XXXXXXXXXX  

          Set wd = CreateObject("Word.Application")  

 '     ##########################  
 '     get values in boxes  
 '     ###########################  

         co = document.train.group.value
         date12 = document.train.date.value

      if document.train.c1.checked = true then
              test1 = "On"  

       '      msgbox(test1)
    end if

           'XXXXXXXXXXXXXXXXX
  ' Open Word
  ' XXXXXXXXXXXXXXXXX

  wd.Visible=TRUE

  Set docNew = wd.Documents.Add

wd.Selection.Font.Name = "Courier New"
wd.Selection.TypeParagraph
wd.Selection.Font.Size = 10
wd.Selection.TypeText "                  "
wd.Selection.TypeText "                                        1500"
wd.Selection.TypeParagraph
wd.Selection.TypeText "                                 Ser 48/015  "
wd.Selection.TypeParagraph
wd.Selection.TypeText "                          "& date12
wd.Selection.TypeParagraph
wd.Selection.TypeParagraph
wd.Selection.TypeText "From:  "
wd.Selection.TypeParagraph
wd.Selection.TypeText "To: " & co
wd.Selection.TypeParagraph
wd.Selection.TypeParagraph
wd.Selection.TypeText "Subj: This is a test "
wd.Selection.TypeText " "
wd.Selection.TypeParagraph
wd.Selection.TypeParagraph
wd.Selection.TypeText "  test"

wd.Selection.TypeParagraph
set table1 = wd.Table.Add

Thanks
Jim



Sun, 28 Nov 2004 21:44:06 GMT  
 How Do I Script Tables and make page breaks form a html Page
Hi Jim,

Quote:
> I have a html page I am using for an interface to a script , It makes
> a formated Word document, everything is typed on it fine , but now I
> want to
> add pagebreak for the second page and a table

> wd.Selection.TypeParagraph
> set table1 = wd.Table.Add

Dim rng as Word.Range

Set rng = table1.Range
rng.Collapse wdCollapseEnd
rng.Select

will put you in a paragraph following the table. Personally, I wouldn't
work with Select the way you do, but with the Range object...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)



Mon, 29 Nov 2004 17:09:17 GMT  
 How Do I Script Tables and make page breaks form a html Page
Cindy , you method has less errors , I had to comment out the dim
statement because it dont work with VBScript.   but I got an error  
"object required: 'table1'

 I dont know if it matters, this code runs in IE 6 as a vbscript
function on the page

here is the code

 Sub frmSubmit_onclick()  

 '     XXXXXXXXx          
 '     Initialize varables  
 '     XXXXXXXXXX  

          Set wd = CreateObject("Word.Application")  

 '     ##########################  
 '     get values in boxes  
 '     ###########################  

         co = document.train.group.value
         date12 = document.train.date.value

      if document.train.c1.checked = true then
         test1 = "On"  

       '   msgbox(test1)
       end if

      if document.train.c2.checked = true then
         test1 = "On"  

       '   msgbox(test1)
       end if

      if document.train.c3.checked = true then
         test1 = "On"  

       '   msgbox(test1)
       end if

      if document.train.c4.checked = true then
         test1 = "On"  

       '   msgbox(test1)
       end if

  'XXXXXXXXXXXXXXXXX  
  ' Open Word
  ' XXXXXXXXXXXXXXXXX

  wd.Visible=TRUE

  Set docNew = wd.Documents.Add

wd.Selection.Font.Name = "Courier New"
wd.Selection.TypeParagraph
wd.Selection.Font.Size = 10
wd.Selection.TypeText "                  "
wd.Selection.TypeText "                                        1500"
wd.Selection.TypeParagraph
wd.Selection.TypeText "                                              
     Ser 48/015  "
wd.Selection.TypeParagraph
wd.Selection.TypeText "                                              
     "& date12
wd.Selection.TypeParagraph
wd.Selection.TypeParagraph
 wd.Selection.TypeText "From:  Commanding Officer, TRIDENT Training
Facility, Kings Bay"
wd.Selection.TypeParagraph
wd.Selection.TypeText "To: " & co
wd.Selection.TypeParagraph
wd.Selection.TypeParagraph
wd.Selection.TypeText "Subj: "
wd.Selection.TypeText " REPORT"
wd.Selection.TypeParagraph
wd.Selection.TypeParagraph
wd.Selection.TypeText "1.  Your Ship and Battle"
wd.Selection.TypeText " Stations Team Trainer"
wd.Selection.TypeText " was completed during the period "
wd.Selection.TypeParagraph
wd.Selection.TypeParagraph
wd.Selection.TypeText "3. The Following evolutions were evaluated "  
 wd.Selection.TypeText "To assist in the goal, Enclosure (1) includes
a table that lists  "
wd.Selection.TypeText " 'Recommended Future Ongoing Training Emphasis
Level' For Each "

Const wdPageBreak = 7
wd.Selection.InsertBreak wdPageBreak
wd.Selection.TypeText "various "  
 wd.Selection.TypeText "watchstation and the group overall. This table
is not a report of "
 wd.Selection.TypeText "performance during your crew's team trainer. "
wd.Selection.TypeParagraph
wd.Selection.TypeParagraph
wd.Selection.TypeParagraph

 Set rng = table1.add
 Set rng = table1.Range
 rng.Collapse wdCollapseEnd
rng.Select

  End Sub  


Quote:
> Hi Jim,

> > I have a html page I am using for an interface to a script , It makes
> > a formated Word document, everything is typed on it fine , but now I
> > want to
> > add pagebreak for the second page and a table

> > wd.Selection.TypeParagraph
> > set table1 = wd.Table.Add

> Dim rng as Word.Range

> Set rng = table1.Range
> rng.Collapse wdCollapseEnd
> rng.Select

> will put you in a paragraph following the table. Personally, I wouldn't
> work with Select the way you do, but with the Range object...

> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/cindymeister
> http://www.mvps.org/word
> http://go.compuserve.com/MSOfficeForum

> This reply is posted in the Newsgroup; please post any follow question
> or reply in the newsgroup and not by e-mail :-)



Mon, 29 Nov 2004 23:06:48 GMT  
 How Do I Script Tables and make page breaks form a html Page
Hi Jim,

You've lost me, here (maybe due to a typo or two?)... I based my
sample on the bit of code you had in your first message. I haven't
clue about how Script works, just VBA. From what I can tell in the
code you posted in your most recent message, it looks like you've
"lost something in the translation". Look at this, again - paying
special attention to Set table1 - and compare to what you've done:

Quote:
> wd.Selection.TypeParagraph
> set table1 = wd.Table.Add

Dim rng as Word.Range

Set rng = table1.Range
rng.Collapse wdCollapseEnd
rng.Select

Quote:
> Cindy , you method has less errors , I had to comment out the dim
> statement because it dont work with vbscript.   but I got an error  
> "object required: 'table1'

>  I dont know if it matters, this code runs in IE 6 as a vbscript
> function on the page

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)



Tue, 30 Nov 2004 18:19:22 GMT  
 How Do I Script Tables and make page breaks form a html Page
Hello Jim,

From your post I assume you want to add a new table on a new page in the
document.  Try this script:

wd.Selection.TypeParagraph

' Insert page break
wd.Selection.InsertBreak 7  ' comment: wdPageBreak = 7

' Insert Table (must specify number of rows and columns)
Set rng = wd.Selection.Range
Set table1 = docNew.Tables.Add (rng, 3, 4)    ' new table has 3 rows and 4
columns

' now move selection beyond table (using information provided by Cindy
Meister)
Set rng = table1.Range
rng.Collapse 0 ' comment: wdCollapseEnd = 0
rng.Select

When using script on a web page, you cannot use Word's constants such as
wdPageBreak so I have replaced them with the actual values in the above
code.

Best regards,
 Greg Ellison
 Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

--------------------

Quote:

>Newsgroups: microsoft.public.office.developer.vba
>Subject: How Do I Script Tables and make page breaks form a html Page
>Date: 12 Jun 2002 06:44:06 -0700

>I have a html page I am using for an interface to a script , It makes
>a formated Word document, everything is typed on it fine , but now I
>want to
>add pagebreak for the second page and a table  help



Fri, 03 Dec 2004 23:26:13 GMT  
 How Do I Script Tables and make page breaks form a html Page
Thank you to all those who that responded. I now have a table on a
word document
from a web page.  Greg , is there somewhere I get more info on the
workings of word and web pages ??

Well the next question I have is how Do I populate the table ??

wd.Selection.TypeParagraph
 Set rng = wd.Selection.Range
 Set table1 = docNew.Tables.Add (rng, 3, 4)
set rng = table1.Range
rng.Collapse 0
rng.Select
wd.Selection.table1.MoveRight.Unit(wdcell)
wd.Selection.TypeText "various "  

I am trying to type    " various" in the top left cell of the table.
Remember I am trying to make this from vbscript in a web page to a
word document

Thanks
Jim


Quote:
> Hello Jim,

> From your post I assume you want to add a new table on a new page in the
> document.  Try this script:

> wd.Selection.TypeParagraph

> ' Insert page break
> wd.Selection.InsertBreak 7  ' comment: wdPageBreak = 7

> ' Insert Table (must specify number of rows and columns)
> Set rng = wd.Selection.Range
> Set table1 = docNew.Tables.Add (rng, 3, 4)    ' new table has 3 rows and 4
> columns

> ' now move selection beyond table (using information provided by Cindy
> Meister)
> Set rng = table1.Range
> rng.Collapse 0 ' comment: wdCollapseEnd = 0
> rng.Select

> When using script on a web page, you cannot use Word's constants such as
> wdPageBreak so I have replaced them with the actual values in the above
> code.

> Best regards,
>  Greg Ellison
>  Microsoft Developer Support

> This posting is provided "AS IS" with no warranties, and confers no rights.

> Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.com/security.

> --------------------

> >Newsgroups: microsoft.public.office.developer.vba
> >Subject: How Do I Script Tables and make page breaks form a html Page
> >Date: 12 Jun 2002 06:44:06 -0700

> >I have a html page I am using for an interface to a script , It makes
> >a formated Word document, everything is typed on it fine , but now I
> >want to
> >add pagebreak for the second page and a table  help



Mon, 06 Dec 2004 03:03:56 GMT  
 How Do I Script Tables and make page breaks form a html Page
Hello Jim,

I'm glad you were able to add the table.  Now to add "Various" to cell 1,1
of the table, do the following:

table1.Cell(1, 1).Range.Text = "Various"

You can add the above line right after you use the Add method to create the
table. For information about the Office object models such as Word, please
see these links:

Q222101 - HOWTO: Find and Use Office Object Model Documentation
http://support.microsoft.com/support/kb/articles/q222/1/01.asp

http://msdn.microsoft.com/library/techart/VSOfficeDev.htm

Best regards,
 Greg Ellison
 Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

--------------------

Quote:

>Newsgroups: microsoft.public.office.developer.vba
>Subject: Re: How Do I Script Tables and make page breaks form a html Page
>Date: 19 Jun 2002 12:03:56 -0700

>Thank you to all those who that responded. I now have a table on a
>word document
>from a web page.  Greg , is there somewhere I get more info on the
>workings of word and web pages ??

>Well the next question I have is how Do I populate the table ??

>wd.Selection.TypeParagraph
> Set rng = wd.Selection.Range
> Set table1 = docNew.Tables.Add (rng, 3, 4)
>set rng = table1.Range
>rng.Collapse 0
>rng.Select
>wd.Selection.table1.MoveRight.Unit(wdcell)
>wd.Selection.TypeText "various "  

>I am trying to type    " various" in the top left cell of the table.
>Remember I am trying to make this from vbscript in a web page to a
>word document

>Thanks
>Jim



Mon, 06 Dec 2004 03:50:18 GMT  
 How Do I Script Tables and make page breaks form a html Page
I want to thank everyone, the project is going great, but I have a new
request.  On the table there is one cell  at the top divided into smaller
segments . That cell is divided into 3 sections , with lines runing top to
bottom
                                                   vvv third cell divided
into three
  ----------------------------------------------
  |              |                |             |     |       |        |
  |              |                |             |     |       |        |
  -----------------------------------------------

how do I do that.. Do I have to make a table in a table ??



Quote:
> Hello Jim,

> I'm glad you were able to add the table.  Now to add "Various" to cell 1,1
> of the table, do the following:

> table1.Cell(1, 1).Range.Text = "Various"

> You can add the above line right after you use the Add method to create
the
> table. For information about the Office object models such as Word, please
> see these links:

> Q222101 - HOWTO: Find and Use Office Object Model Documentation
> http://support.microsoft.com/support/kb/articles/q222/1/01.asp

> http://msdn.microsoft.com/library/techart/VSOfficeDev.htm

> Best regards,
>  Greg Ellison
>  Microsoft Developer Support

> This posting is provided "AS IS" with no warranties, and confers no
rights.

> Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.com/security.

> --------------------

> >Newsgroups: microsoft.public.office.developer.vba
> >Subject: Re: How Do I Script Tables and make page breaks form a html Page
> >Date: 19 Jun 2002 12:03:56 -0700

> >Thank you to all those who that responded. I now have a table on a
> >word document
> >from a web page.  Greg , is there somewhere I get more info on the
> >workings of word and web pages ??

> >Well the next question I have is how Do I populate the table ??

> >wd.Selection.TypeParagraph
> > Set rng = wd.Selection.Range
> > Set table1 = docNew.Tables.Add (rng, 3, 4)
> >set rng = table1.Range
> >rng.Collapse 0
> >rng.Select
> >wd.Selection.table1.MoveRight.Unit(wdcell)
> >wd.Selection.TypeText "various "

> >I am trying to type    " various" in the top left cell of the table.
> >Remember I am trying to make this from vbscript in a web page to a
> >word document

> >Thanks
> >Jim



Thu, 16 Dec 2004 09:47:49 GMT  
 How Do I Script Tables and make page breaks form a html Page
Hi Jim,

A nested table would be one option, if this is only to run in Word 2000 or
later.

Another possibility would be to simply "split" the cell. In the UI, you
select the cell, the Table/Split; Split method of the CELL object in the
Word object model.

Quote:
> On the table there is one cell  at the top divided into smaller
> segments . That cell is divided into 3 sections , with lines runing top to
> bottom
>                                                    vvv third cell divided
> into three
>   ----------------------------------------------
>   |              |                |             |     |       |        |
>   |              |                |             |     |       |        |
>   -----------------------------------------------

> how do I do that.. Do I have to make a table in a table ??

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



Thu, 16 Dec 2004 15:55:20 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. How To Fill In An HTML Form On A Web Page Using A Standalone .VBS Script

2. Page Breaks in HTML when printing a report from IE

3. add page break to bottom of each page?

4. Next page section break with continuous page numbering

5. Page Breaks in Web Page

6. Break page in a RTF document (RichTextBox New Page)

7. Group Page Break without blank page?

8. Break page in a RTF document (RichTextBox New Page)

9. Delete page break/merge tables

10. Building Tables, and page breaks

11. Break Word Table columns and show in next page

12. replace page breaks with section breaks

 

 
Powered by phpBB® Forum Software