Control Indentation Hanging in PowerPoint 2010 VSTO - vba

I have a paragraph and after executing :
paragraph.ParagraphFormat.FirstLineIndent = 18;
paragraph.ParagraphFormat.LeftIndent = 18;
when I check Paragraph dialog box, I get:
Indentation Before Text 0.25" - OK, this is what I wanted
Special First line 0.25" - it's not what I want.
Instead of First line I want to have Special set to Hanging. Is it possible to control it with code?

Instead of First line I want to have Special set to Hanging. Is it possible to control it with code?
Yes it is possible :)
Just remember the thumb rule
For FirstLine use a positive value and
For Hanging use a negative value
Change your code to
paragraph.ParagraphFormat.FirstLineIndent = -18;

Related

Mapping Keyboard Shortcuts in Word (vba) KeyBindings.Add KeyCategory: = wdKeyCategoryCommand, Command: = "..."

Good day.
Someone has a list of the commands that can be assigned a keyboard shortcut using the function:
KeyBindings.Add KeyCategory: = wdKeyCategoryCommand, Command: = "..."
I want to assign a shortcut to decreasing French indentation, but I only see the command for its increase: Command: = "HangingIndent"
Thank you. Greetings.
Choose Developer>Macros. Change the Macros in dropdown to Word commands. The complete list of available command names is displayed.
If you need to set specific indentation amounts, you'll have to write a simple macro instead of relying on Word's preset indentation values.
But it's probably better to avoid VBA altogether. Instead of relying on local formatting (which a Word command or macro would do), create a typestyle with your preferred indentation and apply that to the text. That's a better practice in Word and easy to update later if you change your mind about the amount of indentation.
The problem is precisely that, that the command related to the decrease of the French indentation does not appear in the list of Word commands. What I need to know is what the said command is called. After a lot of thinking I found a command to list all the keyboard shortcuts in the active document: Application.Run MacroName: =" CommandList" and this allowed me to find what I'm looking for: RemoveHangingIndent

VBA Macro for MS Word to Ignore Spelling Errors in Selected Block of Text

VBA Noob here. I take my python programming notes in a word document since I can import images into it and align/format text quickly. Any code pasted into this document comes up as a spelling error. I'm trying to find a way to ignore spelling errors within a selected text area so I don't have to deal with ignoring each spelling error line of code individually. I don't want to turn off spell check in the document.
Ideally, I'd able to write a macro that read:
Selection.ShowSpellingErrors = True
but ShowSpellingErrors() can only be used with ActiveDocument. I was able to a record a macro that ignored spelling errors with:
Selection.LanguageID = wdEnglishUS
Selection.NoProofing = True
However, any new text I type into this also doesn't get proofed, which is something I don't want. I want to be able to write new text and see any errors I make. Thanks for any help!
Not a VBA Macro, but I think this answer may be relevant to your problem anyway.
Try creating a style for code which does not include spell check. Anything with this style does not get spell checked, while the rest of the document does. Sometimes I find the code shows the red underline, but if you run spell check it should just disappear without needing to be 'fixed'.
Create a new style, in the modify formatting dialog, go to Format > Language:
Tick the 'Do not check spelling or grammar' checkbox:
Highlight your code and use the new style. Any text not in this style will still be spellchecked:

indentation in PowerPoint 2013

I would like to change text indentation in some PowerPoint object.
Paragraph -> Indentation -> before text
Paragraph -> Indentation -> Special -> Hanging (how to change it on FirstLine or None?) -> By
From that what I've found in previous versions it could be done with
paragraph.ParagraphFormat.FirstLineIndent = x;
paragraph.ParagraphFormat.LeftIndent = x;
but now there is no such properties available.
Okay, I figured it out. Here's the trick: the LeftIndent and FirstLineIndent properties only exist on the Microsoft.Office.Core.ParagraphFormat2 object. They do not exist on the regular Microsoft.Office.Interop.PowerPoint.ParagraphFormat object.
You can still change the format for an entire TextRange though (it doesn't have to be done at the paragraph level as the comments above specify).
The trick is to access your shape's TextFrame2 property, instead of just TextFrame, this will ensure that the classes you get back are TextRange2, which will return a ParagraphFormat2 instead of a regular TextRange and ParagraphFormat.
The following code worked for me:
myShape.TextFrame2.TextRange.ParagraphFormat.LeftIndent = (.13f * 72f); // .13 inches

automating word 2010 to generate docs

the webapp was already done on office2007 and i need to convert it so it'll work in office2010.
i was able to convert the header generator part of the code but i have problem with the body of the doc itself. the code copy the data from a "data" doc and paste it into the generated doc.
appword.activewindow.activepane.view.seekview = 0
'set appsel1 = appword.activewindow.selection
set appsel1 = appword.window(filepath).selection -that is the original one
appdoc1.bookmarks("b1").select
appword.selection.insertafter("some text")
appsel1.endkey(6) -the code stops here
appword.selection.insertafter("some other text")
the iexplorer debuger says ERROR:appsel1 object required. and when i view its data using the iexplorer debugger its data is "empty" instead of "{...}"
can anyone tell me what i'm doing wrong
if you need more of the code tell me.
From MSDN
After this method is applied, the selection expands to include the new
text.
If you use this method with a selection that refers to an entire
paragraph, the text is inserted after the ending paragraph mark (the
text will appear at the beginning of the next paragraph). To insert
text at the end of a paragraph, determine the ending point and
subtract 1 from this location (the paragraph mark is one character).
However, if the selection ends with a paragraph mark that also happens
to be the end of the document, Microsoft Word inserts the text before
the final paragraph mark rather than creating a new paragraph at the
end of the document.
Also, if the selection is a bookmark, Word inserts the specified
text but does not extend the selection or the bookmark to include the
new text.
So I suspect that you still have no selected text.
I wonder if you can do a Selection Collapse(wdCollapseStart) but that's just a thought.

Remove paragraph mark when copying from excel cell

Please help me copy a string from a listbox when a user hits ctrl+c. I was using the dataobject but for some reason this worked perfectly some times and gave me an error message other times. If you know why this is, stop reading, as the rest of this question is not necessary.
Now I am putting this in a worksheet cell and using range.copy, however, when the string is pasted into a textbox, it retains the paragraph mark that excel seems to put at the end of every cell! Just to make things fun, the paragraph mark cannot be removed by using Left() - it takes everything but the paragraph mark. (Paragraph mark below is represented by P).
s = "stringP"
s = Left(s,len(s)-1)
print s
returns: strinP
Has to be something simple I'm missing.
I haven't tested this but have you tried chopping two characters?
I'm sure it's \r\n or carriage-return + line feed, not just \n you need to chop.
Have you tried trim() function ?
And why do you have to use Range.copy?
Can't you just assign textbox1.value = Range("A1") ?
It works fine without any bugs.