#1
|
|||
|
|||
Word 2013 Display image by click
Hi,
I want to display some images just by clicking on text and this image will be hidden if I click again. Is there a way to do that? I don't know if it's clear. Regards, |
#2
|
||||
|
||||
You could do this using floating shapes, combined with a MACROBUTTON field coded along the lines of:
{MACROBUTTON ShowHide Text_to_be_clicked} and a macro like: Code:
Sub ShowHide() With ActiveDocument.Shapes(1) .Visible = Not .Visible End With End Sub Note: The field brace pairs (i.e. '{ }') for the above example are created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thank you for your help.
I never did a macro before, and I just succeed in create it. I did "create a macro" that I named "ShowHide" and I put the code you told me. But I don't know what doing after. Where Do I have to put my text which will display the image by a click? How can I do to put the image I want to display? Furthermore, when I try to save, it says me that I can't save a VBA project in a file without macro. Regards, |
#4
|
||||
|
||||
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm.
To create the MACROBUTTON field, select the text that is to be clicked and press Ctrl-F9 to enclose it in a pair of field braces, thus {Text_to_be_clicked}. Then fill in the rest of the field code, so you end up with {MACROBUTTON ShowHide Text_to_be_clicked}. Once you've done that, press F9 to update the field. For the picture, simply insert it anywhere into the document and make sure it's format is not set to 'in line with text'. Done. Now, any time you double-click on the 'Text_to_be_clicked' that will toggle the image's display on/off. As for the saving issue, you'll need to save the document as either a macro-enabled document (.docm format) or in the older .doc format.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Thanks again.
I read the link you gave me. But I'm still blocked :/ I did this : To create the MACROBUTTON field, select the text that is to be clicked and press Ctrl-F9 to enclose it in a pair of field braces, thus {Text_to_be_clicked}. Then fill in the rest of the field code, so you end up with {MACROBUTTON ShowHide Text_to_be_clicked}. Once you've done that, press F9 to update the field. I had "Afficher" and I did ctrl+f9 and put {MACROBUTTON ShowHide Afficher} and did f9. My macro is ShowHide and is : Sub ShowHide() With ActiveDocument.Shapes(1) .Visible = Not .Visible End With End Sub I would like to know how link this macro with a specific picture (because I want to do other similar macros for other pictures). And I want the picture to be hidden at the beginning. Thanks, Regards, |
#6
|
||||
|
||||
See attached. Double-clicking anywhere in 'Nunc viverra imperdiet enim' in the 2nd para toggles the image.
The code is written to toggle the first image in the document. If you want multiple images, controlled by multiple MACROBUTTON fields, you'll need a different Sub name for each (e.g. ShowHide1, ShowHide2, etc), referenced in the corresponding MACROBUTTON field, with the macro code referencing the applicable image # (e.g. Shapes(1), Shapes(2), etc.) Note that the image #s are determined according to their anchor positions in the document, not their placement on the page.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Ok I want exactly the same thing that in your document.
I attach mine, can you say me why it doesn't work please? Thanks, |
#8
|
||||
|
||||
The only thing 'wrong' with your document is that you haven't added the macro to it.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Ok I failed ...
I think this time there is a macro in the document. If there isn't the macro again, I can say you that I Have a macro ShowHide : Sub ShowHide() With ActiveDocument.Shapes(1) .Visible = Not .Visible End With End Sub And I have this : {MACROBUTTON ShowHide AFFICHER}, the picture isn't inline. Thanks again, sorry I'm a noob with macro. |
#10
|
|||
|
|||
Ok I've found that it works.
The problem is that I put a "cover page" and this is it that is hidden. How can I do to make disappear the second image and not the "cover page"? |
#11
|
||||
|
||||
As indicated in post #6, the image #s are determined according to their anchor positions in the document, not their placement on the page. Since the image on the cover page is, presumably, image #1, try changing .Shapes(1) to .Shapes(2) in the macro.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#12
|
|||
|
|||
Ok thank you very much
I would like to know 2 last things : -How can I make move the text when I show or hide the picture? I've put the text after the picture and when I hide the picture, the texte doesn't move. -Is it possible to hide the pictures when I open the document? When I open, I want the pictures to be hidden, and I show if I want. Thank you again. Regards, |
#13
|
||||
|
||||
With your existing image, the 'top & bottom' wrap format means the text should move out of the way when the image is displayed.
If you save the document with the images invisible, they should still be that way when the document is re-opened. The document will always open with the same images visible/invisible as when it was last saved.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#14
|
|||
|
|||
Ok thanks it works like I want
I think we can say it's resolved. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
1.image in a table 2.right click 3.menu click format 4.a format column appears | OldFatDog | Drawing and Graphics | 1 | 06-13-2014 11:19 PM |
Word 2013 Page Display | ebbieday | Word | 1 | 04-08-2014 09:24 AM |
Need: User to click image and leave red dots or circles | nursenerd | Word VBA | 6 | 03-16-2014 02:41 PM |
Call for votes: office 2013 Autocorrect & right click (context menu) | franklekens | Word | 0 | 09-20-2013 12:09 AM |
Display the properties of an embedded image | tmazzotta | PowerPoint | 0 | 02-18-2011 05:41 PM |