+ Reply to Thread
Results 1 to 6 of 6

Insert Shape on Page

  1. #1
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Insert Shape on Page

    I am printing a multipage document and insert a page changes a certain new topics. On each page, i am trying add a horizontal line shape after the topic first paragraph on each page. The below code works for all pages but the line is only drawn on the first page. On subsequent pages, the horizontal line is not drawn anywhere on any following page. What code changes do I need to make to get the line drawn on each page.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Insert Shape on Page

    Without access to your document, it's impossible to understand what that code is actually doing. The coding is strange, to say the least. For example:
    • you're creating a Word object, but you wouldn't do that if the macro is being run in Word;
    • WordDoc.Paragraphs(WordDoc.Paragraphs.Count).Range is a convoluted way of getting WordDoc.Paragraphs.Last.Range; and
    • you have a loop controlled by 'Do While recno <= recount', but recno is set to 1 and recount is 0 (it's never set, so it's always 0) and the loop will thus never execute.
    One might also ask why you don't just set your line via a bottom border that's part of whatever your 'Style_RecipeTitle' Style is, instead of trying to do all this via code and shape objects.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: Insert Shape on Page

    I tried to simplify the code and inadvently left out the increment of recno. I am running this from Excel macro. I was using the line to simplify things but actually will use a picture when I get this sorted out. I have also tried to insert a shape at the Selection where I set th selection as "Set wselect = WordDoc.Paragraphs(WordDoc.Paragraphs.Count).Range.select". This selects the proper point in the document as text is being added via my above code.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Insert Shape on Page

    As I said:
    Without access to your document, it's impossible to understand what that code is actually doing.
    And, given your latest post, we'd need to see both the full code and the Excel workbook it relates to.

    Can you attach a document and workbook to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.

  5. #5
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: Insert Shape on Page

    My file has over 3000 lines of vba code as it is an excel program for entering and recovering recipes from an Access database using late binding. It includes robust food recipe details including scaleable ingredients for various serving sizes. I tried to post the relevant code for printing rather than the full code. I am searching the internet and reading and getting close using the selection object to position pictures and other shapes. Thanks anyway.

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Insert Shape on Page

    Quote Originally Posted by EssoExplJoe View Post
    I tried to post the relevant code for printing rather than the full code.
    Fair enough, but nothing in the code has anything to do with printing, per se, notwithstanding the frequent comments in it re printing; it only concerns page formatting and content. But it also includes code for which there is no context, e.g.:
    rec = Read_record(recs(recno).keyid, emsg, True, conn)
    pgstyle.ParagraphHalfSpace
    I'd have to wonder, too, whether what you're doing is better suited to a mailmerge, even automated, than your current approach.

    Without access to at least a sample document, however, I'm just left guessing at what the code's supposed to achieve - especially when you post code for inserting a line but later say you'll insert a picture instead and what you've posted replaces detail with:
    ....print some more stuff

+ 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. [SOLVED] excel VBA insert pagebreak after shape
    By wambaugh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-09-2015, 04:30 PM
  2. [SOLVED] Insert Diamond Shape for every Row and add cell value to each shape
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 34
    Last Post: 04-02-2013, 10:10 AM
  3. Can't Insert Shape to sheet [1]
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2012, 02:23 PM
  4. repeat shape on every page
    By noobtron in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-19-2012, 04:40 PM
  5. Insert Shape.
    By JapanDave in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2011, 08:13 AM
  6. Insert cell content into a shape
    By anmck in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-09-2011, 02:50 PM
  7. Insert/draw a line (as a shape)
    By Jeroen1000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2009, 10:21 AM

Tags for this Thread

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