+ Reply to Thread
Results 1 to 13 of 13

inserting page break in word doc created from excel spreadsheet

  1. #1
    Registered User
    Join Date
    03-03-2014
    Location
    Albany, NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    inserting page break in word doc created from excel spreadsheet

    I have a word document that I create from data in an excel spreadsheet to create reports. I need to insert a page break at the end of each report. The code I have is below. The error I receive is:
    Object doesn't support this property or method.
    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: inserting page break in word doc created from excel spreadsheet

    Hello twyblue,

    You did not declare the Word constants. Remember from yesterday? Any named constant starting with wd is not available at compile time because you are using late binding.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    03-03-2014
    Location
    Albany, NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: inserting page break in word doc created from excel spreadsheet

    I thought I did - at the top I placed

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: inserting page break in word doc created from excel spreadsheet

    Hello twyblue,


    How about wdDoNotSaveChanges?

    Also did not a Const for this one wdCollapseEnd.

  5. #5
    Registered User
    Join Date
    03-03-2014
    Location
    Albany, NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: inserting page break in word doc created from excel spreadsheet

    It actually all works except inserting the page break without declaring the other word constants. If I comment out inserting the page break, it exports to pdf and closes the open word files without any problem.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: inserting page break in word doc created from excel spreadsheet

    Hello twyblue,

    You got lucky this time because the other constants have zero values. Shortcuts more often than not will come back to haunt you. Practice good coding habits now and you will still hair when you're sixty.

    Can you attach a copy of the workbook for review?

  7. #7
    Registered User
    Join Date
    03-03-2014
    Location
    Albany, NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: inserting page break in word doc created from excel spreadsheet

    Attached is the word doc I populate from the excel spreadsheets. For multiple reports, I populate the document, add it to a new document, then close and re-open the template, populate with next report, etc.
    Attached Files Attached Files

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: inserting page break in word doc created from excel spreadsheet

    Hello twyblue,

    Is the error occurring on the line where the page break is inserted?

    If this is a single page document, why do you need to insert a page break?

  9. #9
    Registered User
    Join Date
    03-03-2014
    Location
    Albany, NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: inserting page break in word doc created from excel spreadsheet

    Yes it is. They can choose just a single report, or all the reports for the department.
    When they choose to view all the reports in one document, I am looping through and creating a document for each report, then adding it to a new temp doc before exporting it to a pdf. I need a page break in the new document after each report so the reports won't run together in the pdf.

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: inserting page break in word doc created from excel spreadsheet

    Hello twyblue,

    It has been awhile since I wrote any Word macros, I need to experiment with code bit to give you an answer.

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: inserting page break in word doc created from excel spreadsheet

    Hello twyblue,

    I need to construct another Word document for testing. Using the one posted is not working correctly and I am not sure why.

  12. #12
    Registered User
    Join Date
    03-03-2014
    Location
    Albany, NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: inserting page break in word doc created from excel spreadsheet

    I am not sure how this exactly works, but placing this line in the code gives me the page break.

    Please Login or Register  to view this content.
    Last edited by twyblue; 03-06-2014 at 10:38 AM.

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: inserting page break in word doc created from excel spreadsheet

    Hello twyblue,

    It works and that what really matters. Good job on finding a solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. trying to export a word document created using excel spreadsheet data to pdf
    By twyblue in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2014, 12:33 PM
  2. [SOLVED] unable to delete page break on Excel spreadsheet
    By sonjsull in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-09-2014, 05:58 PM
  3. Removing Existing Page Breaks and Inserting a Page Break every third Total Line
    By Kalvas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-17-2013, 05:12 AM
  4. inserting page break in ms word using macro
    By anjali5 in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2013, 06:31 AM
  5. Inserting Page Break
    By jp16 in forum Excel General
    Replies: 0
    Last Post: 04-13-2012, 10:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1