word-vba

Program the Navigation Pane in Word 2010

回眸只為那壹抹淺笑 提交于 2019-12-01 23:26:19
问题 I'm trying to find a way to program the new Navigation pane in Word 2010 to change tabs when a user selects a picture in the document. I can capture the selection change with WindowSelectionChange(ByVal Sel As Selection) , but I can't figure out how change the tab from "Browse the headings" to "Browse the pages", which is what I want. 回答1: According to the MVP on this thread, it's not programmable/searchable. 回答2: It is possible using iAccessible! Dim As IAccessible Set oIA = CommandBars(

Recheck Document For Spellings Not Same as VBA Code

佐手、 提交于 2019-12-01 21:46:08
I want to recheck the spellings in a document after adding a dictionary. The problem is the following code (mostly from the macro recorder) CustomDictionaries.Add FileName:="c:\test_dictionary.dic" Application.ResetIgnoreAll ActiveDocument.Range.SpellingChecked = False ActiveDocument.Range.GrammarChecked = False does not produce the same results as from the Word 2007's Word Options|Proofing|Recheck Document button. The button does recheck the document and you can see the newly added words get removed as misspellings. The code does not have any noticable affect. What am I overlooking? This is

Macro to update all fields in a word document

对着背影说爱祢 提交于 2019-12-01 18:21:14
I have built - over the years - a vba macro that is supposed to update all fields in a word document. I invoke this macro before releasing the document for review to ensure all headers and footers etc are correct. Currently - it look like this: Sub UpdateAllFields() ' ' UpdateAllFields Macro ' ' Dim doc As Document ' Pointer to Active Document Dim wnd As Window ' Pointer to Document's Window Dim lngMain As Long ' Main Pane Type Holder Dim lngSplit As Long ' Split Type Holder Dim lngActPane As Long ' ActivePane Number Dim rngStory As Range ' Range Objwct for Looping through Stories Dim TOC As

vba: return page number from selection.find using text from array

雨燕双飞 提交于 2019-12-01 18:07:46
(Note: See below for solution.) I have been trying to retrieve the page numbers from pages that various headings reside on in a word document using VBA. My current code returns either 2 or 3, and not the correctly associated page numbers, depending on where and how I use it in my main Sub. astrHeadings = docSource.GetCrossReferenceItems(wdRefTypeHeading) For Each hds In astrHeadings docSource.Activate With Selection.Find .Text = Trim$(hds) .Forward = True MsgBox hds & ":" & Selection.Information(wdActiveEndPageNumber), vbOKOnly End With Selection.Find.Execute Next docSource is a test document

vba: return page number from selection.find using text from array

谁都会走 提交于 2019-12-01 17:43:30
问题 (Note: See below for solution.) I have been trying to retrieve the page numbers from pages that various headings reside on in a word document using VBA. My current code returns either 2 or 3, and not the correctly associated page numbers, depending on where and how I use it in my main Sub. astrHeadings = docSource.GetCrossReferenceItems(wdRefTypeHeading) For Each hds In astrHeadings docSource.Activate With Selection.Find .Text = Trim$(hds) .Forward = True MsgBox hds & ":" & Selection

Close/Release Word object in VBA?

懵懂的女人 提交于 2019-12-01 16:37:12
问题 I have the following code to open the manual for an Excel Workbook application I have developed: Sub OpenManual() 'Word.Application.Documents.Open "\\filePath\FormFlow To MSExcel\FeedSampleReport-Manual.docx" Dim objWord As Object Set objWord = CreateObject("Word.Application") objWord.Visible = True objWord.Documents.Open "\\filePath\FormFlow To MSExcel\FeedSampleReport-Manual.docx" End Sub This gives me 2 issues though: The document opens, but in the background. The user doesn't know the

“Run-time error 462 : The remote server machine does not exist or is unavailable” when running VBA code a second time

匆匆过客 提交于 2019-12-01 16:05:23
The code below is working fine the first time I run it, but when I need to run it a second time , it gives me this error: Run Time error '462': the remote server machine does not exist or is unavailable It doesn't happen all the time so I suppose it has something to do with Word (not) running in the background...? What am I missing here? Sub Docs() Sheets("examplesheet").Select Dim WordApp1 As Object Dim WordDoc1 As Object Set WordApp1 = CreateObject("Word.Application") WordApp1.Visible = True WordApp1.Activate Set WordDoc1 = WordApp1.Documents.Add Range("A1:C33").Copy WordApp1.Selection

ms word 2010 macro How to select all shapes on a specific page

自作多情 提交于 2019-12-01 13:51:52
The command ActiveDocument.Pages(1).Shapes.Range.Select doesnot seem to work in word 2010. (It used to work in word 2003). I need to select all the shapes on a specified page (say page 1), then delete the first shape and last shape on each page of a 300 page word document. Any help on how to do this will be of great help. Regards Firaq pasto UPDATE1 - Removed (only works on inline shapes) UPDATE2 - Removed (only works on inline shapes) UPDATE3 - Removed (Delete using the Shape's Name not necessary the right Shape as they can all be the same) UPDATE4 - Check and Delete using Shape's ID. To

Calculation fields not working with dates

两盒软妹~` 提交于 2019-12-01 13:30:30
I have seen quite a lot of examples looking for a solution, so I'm pretty certain that this possible. I have Custom Document Properties (properly defined as date) containing dates , and I want to make operations on them : {={ DOCPROPERTY DateFieldTest }+1 \@"d MMMM YYYY"} 'toggle DOCPROPERTY Field {=07/04/2016+1 \@"d MMMM YYYY"} 'toggle calculation field 1 I have also tried : {=DATE(YEAR({ DOCPROPERTY DateFieldTest }),MONTH({ DOCPROPERTY DateFieldTest }),DAY({ DOCPROPERTY DateFieldTest })+1) \@"d MMMM YYYY"} 'toggle DOCPROPERTY Field {=DATE(YEAR(07/04/2016),MONTH(07/04/2016),DAY(07/04/2016)+1)

Event - Document Edited

烂漫一生 提交于 2019-12-01 11:06:56
Is there an event for when a document is edited? If not, does anyone know where I could find a list of the available VBA events? Here are the events for the document object: http://msdn.microsoft.com/en-us/library/aa140279(office.10).aspx Events DocumentBeforeClose : Immediately before any open document closes. DocumentBeforePrint : Before any open document is printed. DocumentBeforeSave : Before any open document is saved. DocumentChange : A new document is created, when an existing document is opened, or when another document is made the active document. DocumentOpen : A document is opened.