+ Reply to Thread
Results 1 to 4 of 4

Add an Inline Button to a Word Document - Getting started

  1. #1
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    319

    Add an Inline Button to a Word Document - Getting started

    I'm running Word 365 and have a need to add a couple of inline command buttons to a document. This is rather like adding a command button to a worksheet in Excel, except that the target is a Word Document not a spreadsheet.

    I have some 'sample' code that I am starting with (copied from a MS SUpport posting):
    Please Login or Register  to view this content.
    The sub zTestAddInlineButton allows me to execute the AddInLineButton sub without having to provide a parameter.

    Everything goes (fairly) well, except that the button gets added in the same place every time. If I move to a different place in the document and run the macro again, it still ends up in the same place (which happens to be the start of the document).

    Obviously (?) there are aspects to adding an OLEControl to the InLineShapes collection that are not being addressed. The properties of an InLineShape include a Range - which should allow me to specify a location. The question then becomes - how do I determine where the cursor is - so I can use those values for the InLineShape.Range?

    This may well be an extended conversation, as most of my experience is with Excel VBA.

    All help and most suggestions appreciated!

    Tony

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    8,030

    Re: Add an Inline Button to a Word Document - Getting started

    To determine where the cursor is you can use "Selection.Range")

    Try adding this line to the top of your code, with the other Dim lines:
    Please Login or Register  to view this content.
    Then changing this line:
    Please Login or Register  to view this content.
    To this:
    Please Login or Register  to view this content.
    That should add the button to the current cursor location.

    Hopefully anyway. I've not used VBA in Word for YEARS!

    BSB

  3. #3
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    319

    Re: Add an Inline Button to a Word Document - Getting started

    Thanks, BSB
    hink I get the same result by using the Range parameter of AddOLEControl.

    There seems to be no linkage back from a control handler (CommandButton1_Click) to the InlineSHape, where there are some useful properties!

    I hear what you say about Word VBA. I did some work in it, about 25 years ago, but have not looked at it since.

    Thanks, again,

    Tony
    I

  4. #4
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,175

    Re: Add an Inline Button to a Word Document - Getting started

    Try:

    Please Login or Register  to view this content.

+ 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. Replies: 5
    Last Post: 10-10-2021, 11:49 PM
  2. Replies: 2
    Last Post: 02-26-2021, 05:37 PM
  3. Linking a Command Button to a Word Document using VBA
    By Blue eyes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-31-2020, 08:17 AM
  4. resize inline images - word 2003
    By johncassell in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2018, 12:43 AM
  5. VBA Excel data through button to specefic place in excisting word document
    By Dikkenek in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-25-2016, 04:03 AM
  6. Add text to Existing Word Document if it Doesn't exist create Word Document
    By unstable81 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-10-2013, 12:15 AM
  7. [SOLVED] Command button to get a Word document
    By Alex Martinez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2005, 08:05 AM

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