word-vba

Is there a way to trigger “track changes” through VBA in Excel?

十年热恋 提交于 2020-01-13 20:29:34
问题 I want from VBA to start/stop "Track changes" functionality in Excel. Searching thru the Net I saw a property called TrackRevisions of ActiveDocument object. Supposedly in MS Word writing ActiveDocument.TrackRevisions = True should turn on "Track changes". But in MS Excel this line gives 424 Object required run-time error. Same error is returned when trying with ThisWorkbook . Changing it to ActiveSheet brings 438 Object doesn't support this property or method error. 回答1: For a shared

Is there a way to trigger “track changes” through VBA in Excel?

元气小坏坏 提交于 2020-01-13 20:29:31
问题 I want from VBA to start/stop "Track changes" functionality in Excel. Searching thru the Net I saw a property called TrackRevisions of ActiveDocument object. Supposedly in MS Word writing ActiveDocument.TrackRevisions = True should turn on "Track changes". But in MS Excel this line gives 424 Object required run-time error. Same error is returned when trying with ThisWorkbook . Changing it to ActiveSheet brings 438 Object doesn't support this property or method error. 回答1: For a shared

How to replace Numbers in Parentheses with some calculations in MS Word

非 Y 不嫁゛ 提交于 2020-01-13 19:24:10
问题 I have a problem to replace some serial number such as [30] [31] [32]... to [31] [32] [33]... in MS word when I insert a new references in the middle of article. I have not found a solution way in GUI so I try to use VBA to do that replacement. I find a similar problem in stack overflow: MS Word Macro to increment all numbers in word document However, this way is a bit inconvenient because it have to generate some replacement array in other place. Can I make that replacement with regex and

How can I loop through every letter in MS Word using VBA?

邮差的信 提交于 2020-01-13 11:37:07
问题 I have about 100 Word documents which include transliteration of foreign names. The author of these documents used a special font called e2 which has about a dozen special transliteration characters (all of which are available in Microsoft Sans Serif font). I would like to loop through every letter of the document and whenever the .Font = "e2" I would like to loop through the dozen letters (it's easy to guess what they are) and replace them with a Microsoft Sans Serif equivalent. But I can't

MS Word - VBA - Adding document property field to footer removes existing page numbering

落爺英雄遲暮 提交于 2020-01-11 14:09:51
问题 I am tying to stamp a document variable field in the footer of every page in a document. I have figured out how to add the field. However, in doing so, the page numbering field that already exists in the footer becomes disabled, leaving only the text and no longer acting as a dynamic page number. Any help would be appreciated. Here is my code that adds the field, but disables the page numbers somehow. (the "sectionFooter.Range.Text = sectionFooter.Range.Text + " "" line is the only way I

Word 2007 VBA - Making some text BOLD & other ITALIC

喜你入骨 提交于 2020-01-11 10:23:21
问题 I have the following code that selects data from an Excel Cell & replaces a specific piece of text in my Word document (for purposes of this question, the Excel Cell has been replaced by a plain text string). The data ": goes to " is constant, then the data "aaa bbb" can be anything until we reach the " of " which is also constant. Then the data after the " of ", "ccc ddd eee" can be anything until it hits the " - " which is also constant. Is it possible to make the "aaa bbb" data BOLD &

MS Word Document Form - Check Value of Text Form Field on Exit

北城以北 提交于 2020-01-07 03:22:48
问题 I'm creating a Form in Microsoft Word. I have several 'Text form fields' some of which I want to restrict so users can only enter numbers. I don't understand why Microsoft gives you the option to change the 'Type' to 'Number' when that still allows any value to be input. Since that seems to be the case I have turned to VBA. I'm trying to run a macro when the user exits one of these fields, to make sure the input is valid. I would rather not create a new macro for each field I want to restrict

MS Word Document Form - Check Value of Text Form Field on Exit

蹲街弑〆低调 提交于 2020-01-07 03:22:10
问题 I'm creating a Form in Microsoft Word. I have several 'Text form fields' some of which I want to restrict so users can only enter numbers. I don't understand why Microsoft gives you the option to change the 'Type' to 'Number' when that still allows any value to be input. Since that seems to be the case I have turned to VBA. I'm trying to run a macro when the user exits one of these fields, to make sure the input is valid. I would rather not create a new macro for each field I want to restrict

Add word document and keep formatting

ε祈祈猫儿з 提交于 2020-01-07 02:50:42
问题 I am attempting to add my CV to the end of a document. The following code does just that but the formatting of the CV is messed up once it is inserted into the new document. Can I insert the file and keep the original formatting of the CV (I dont want to copy and paste from an open document): objword1.Selection.InsertFile Filename:=cv1Address, _ ConfirmConversions:=False, Link:=False, Attachment:=False 回答1: I'm afraid that you can't use the InsertFile-method but have to open the file and copy

Modify Context menus

时光毁灭记忆、已成空白 提交于 2020-01-06 20:29:20
问题 I have the following code to add a menu item on the Word 2013 right click menu: Sub CreateMenuItem() Dim MenuButton As CommandBarButton With CommandBars("Text") Set MenuButton = .Controls.Add(msoControlButton) With MenuButton .Caption = ChrW(&H2714) '"Correct" .Style = msoButtonCaption .OnAction = "InsertMark" End With End With End Sub The issue is that the new menu item is not displayed when I right click on a Text box or a table. How do I remove a menu item that is not used by me, for