In PowerPoint 2007, PickUp/Apply does not capture some paragraph formatting, such as bullet formatting, when used programmatically (VBA). Adding the PickUp and Apply buttons to the Quick Access Toolbar (QAT) and trying this manually confirms this.
However, if you triple-click on a bulleted paragraph and select PickUp from the QAT, then go to another bullet in another shape, triple-click it, then select Apply from the QAT, the bullet formatting is successfully applied.
Programmatically, my approach was then to select all paragraphs in the source shape and use PickUp, then select all paragraphs in the target shape and use Apply. That didn't work. For example, I tried several variations on the following:
'oSource.TextFrame.TextRange.Select
oSource.TextFrame.TextRange.Paragraphs.Select
oSource.PickUp
'oTarget.TextFrame.TextRange.Select
oTarget.TextFrame.TextRange.Paragraphs.Select
oTarget.Apply
So, how can I make PopwerPowin 2007 apply the paragraph formatting in one shape to another, without copying each Paragraph property individually, either using PickUp/Apply or some other technique (in VBA, of course)?
Related
I have a word document that contains text boxes (about 30 of them) that are moved around. I need to know the order of the boxes.
In Word 2016 Activedocument.Shapes returns the shapes in the order they appear in the document, however that is not the case for Word 2007 (they are in the order they were added). Since I want it to work in Office 2007 I'm looking for a workaround.
I use box.wrapformat.Type = WdWrapType.wdWrapInline to convert the boxes to act like inline shapes since .ConvertToInlineShape isn't available in office 2007 but this doesn't actually convert them to inline shapes.
Edit: I just noticed neither does .ConvertToInlineShape. The box doesn't appear in the InlineShapes collection but if I select it the selection type is wdSelectionInlineShape.
Is there a way to force Word to reassign the shapes in the shapes collection or is there another way to get references to the shapes in the correct order?
I am thinking about looping through the characters of the document (selecting each and checking the type) but this seems rather slow.
Is there a reason why my MS Word VBA macro is ignoring a dropdown list I placed inside a shape (a rich text box)? I've tried referring to it by tag, name, number, etc. I even had the macro tell me the count of content controls:
MsgBox(ActiveDocument.ContentControls.Count)
I get 0.
Nothing works. If I take it out of the shape, it works fine. MS Word gives me a count of 1 item. But for some reason MS Word won't acknowledge it inside the shape. Any help on how to do this?
Edited as my previous post was completely wrong.
Each textbox in the main text story is a Shape which you can access using an index number. A shape has various properties but text etc. is in its Textframe, if it has one. But in that case the Range you need is not called Range but TextRange. So, e.g. the first contentControl in Shape 2 is
ActiveDocument.Shapes(2).TextFrame.TextRange.ContentControls(1)
You will probably need to iterate through your shapes and you may need to verify that a given shape is a textbox and/or that it has a TextFrame.
If your text box is in another Story such as a header or footer, you will probably need to identify the relevant StoryRange.
I need to create a macro for the notes in a PowerPoint.
I need to search for a work (aka "tip") - when I find it, I need to change the word to ALL CAPS (aka TIP) and change the entire paragraph to red.
If the paragraph in the notes doesn't have the word - then it needs to stay black.
What is the best way to do this?
I have a word document that is littered with hyperlinks. The links themselves work fine, but for some reason, most of them are not blue anymore! All I'm really looking to do is try to find a way to use a macro or something to go through the document and add the "Hyperlink" style format to each hyperlink.
I tried to edit some macro code myself (one that changes all the links URLs), but I keep making the problem worse! I used to be good at VBScript, but it's been ages since then.
Any easy solution that doesn't involve manually changing each style?
As a side note, all of them currently are in "Normal" style, for some reason.
Try to execute this VBA script (best in debugging mode using the F8 key - have VBA and Word windows side by side so you can see what's happening):
Sub FormatLinks()
Dim H As Hyperlink
For Each H In ActiveDocument.Hyperlinks
H.Range.Select ' (A)
Selection.ClearFormatting ' (B)
H.Range.Style = ActiveDocument.Styles("Hyperlink") ' (C)
Next H
End Sub
This will
cycle through all hyperlinks in your document (A),
remove any formatting on the underlying text (B) and
assign the undrelying text to style "Hyperlink" (C)
(C) is not strictly necessary, as (B) should already sanitize your document, but maybe better to have hyperlinks really assigned to style "Hyperlink" because you may want to change the style later on.
Hi I've a 200 pg fully formatted word document. The person who had worked on it earlier had not applied any style to the whole document and he has done it manually. Though the formatting was done very neatly it has become my job to assign character/paragraph styles to each and every paragraph. Does any one know of a script which assigns character/paragraph styles automatically to the existing word 2010 document?
You'd better use Word VBA to deal with your issue.
What you should do is:
Find the style you want to replace with a style (see MSDN or some tips)
Apply style to the found selection (see this SO thread: How do I apply a style to multiple selections in Word using VBA?)
If you want to check the right style, you can record a macro and adapt it.
You can use the Find and Replace dialog to find text based on its format (e.g. Bold, Size 14) and replace it with a Style (e.g. Heading 2).
This article sums it up pretty well....
http://www.howtogeek.com/howto/microsoft-office/search-and-replace-specific-formatting-fonts-stylesetc-in-microsoft-word/