word-2010

Disable the Save As Button in Word 2010

强颜欢笑 提交于 2019-12-01 08:40:55
I have the following code that should disable the Save As button in Word 2010. The method below is being called in the Document_Startup event: private void DisableSaveAsButton() { Object MenuBar = 40; Object FileMenu = 1; Object SaveAsButton = 5; var saveAsBtn = this.ThisApplication.CommandBars[MenuBar].Controls[FileMenu].accChild[SaveAsButton] as CommandBarButton; saveAsBtn.Enabled = false; } I am expecting the Save as Button to be grayed out, but it isn't and it still functions. What am I doing wrong? Blade3 I figured it out. I just had to add a Ribbon XML item to the project with the

Disable the Save As Button in Word 2010

ぃ、小莉子 提交于 2019-12-01 07:22:53
问题 I have the following code that should disable the Save As button in Word 2010. The method below is being called in the Document_Startup event: private void DisableSaveAsButton() { Object MenuBar = 40; Object FileMenu = 1; Object SaveAsButton = 5; var saveAsBtn = this.ThisApplication.CommandBars[MenuBar].Controls[FileMenu].accChild[SaveAsButton] as CommandBarButton; saveAsBtn.Enabled = false; } I am expecting the Save as Button to be grayed out, but it isn't and it still functions. What am I

OpenXml Table error “<p> elements are required before every </tc>”

我只是一个虾纸丫 提交于 2019-11-30 23:48:31
问题 I have created a Word template that I am then processing via the OpenXML SDK to replace some of the content of the document with data from a database query. The template consists of some basic text with Plain Text Content controls injected in the places that I want to replace the text. I am then using the text in these controls as a key to lookup the replacement values. In most cases, this is working fine (I simply update the Text property of the Text object). In one case I am replacing the

Sending text to Mail-Merge Fields in Microsoft Word 2010

℡╲_俬逩灬. 提交于 2019-11-30 17:04:38
I'm using the following code to send a text to a simple word template I've set up just with a single MergeField at present to test I can get this working. The code I am using is as follows: public static void ReplaceMailMergeField(string pWordDoc, string pMergeField, string pValue) { object docName = pWordDoc; object missing = Missing.Value; Word.MailMerge mailMerge; Word._Document doc; Word.Application app = new Word.Application(); app.Visible = false; doc = app.Documents.Open(ref docName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,

Create Range from current cursor position Word 2010 VBA

笑着哭i 提交于 2019-11-30 14:24:54
问题 I have a .docm document with a user form. On the user form I have a button that needs to insert something (some text, for starter) at the last known cursor position in the document. For this, I want to create a range. How can I get the starting position for this range? 回答1: Selection is the current position in the document. Selection.Range is the Range object of the current Selection . Range.Start is the start position of a Range object (returns or sets a Long). If you combine those three you

How can I reliably get the number of pages in a Word document?

我与影子孤独终老i 提交于 2019-11-30 08:54:53
I am making lots of changes to a Word document using automation, and then running a VBA macro which - among other things - checks that the document is no more than a certain number of pages. I'm using ActiveDocument.Information(wdNumberOfPagesInDocument) to get the number of pages, but this method is returning an incorrect result. I think this is because Word has not yet updated the pagination of the document to reflect the changes that I've made. ActiveDocument.ComputeStatistics(wdStatisticPages) also suffers from the same issue. I've tried sticking in a call to ActiveDocument.Repaginate ,

With a Word ContentControl DatePicker how do i get the value?

元气小坏坏 提交于 2019-11-29 15:32:08
I have a ContentControl that is a DatePicker in a word document. I'm trying to use it to populate some value in a code behind but I cant seem to get the value out of it. Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, _ Cancel As Boolean) None of the properties on ContentControl are close to .Value or .Text. I have seen other content controls use: ContentControl.DropdownListEntries(1).Text ContentControl.DropdownListEntries(1).Value This, as expected for a DatePicker, does not work but it is the only property of ContentControl that returns anything close to

Mailmerge dynamic hyperlink fields lost after save/reload of document - Word 2010

久未见 提交于 2019-11-28 09:28:17
问题 I have a problem where using dynamic hyperlinks in field codes works fine when I create a document, but when save and later reload it the links are replaced with text from the original recordset. The field code I am using is: { HYPERLINK { MERGEFIELD "Fieldname" } \* MERGEFORMAT } After saving then reloading the document this becomes similar to: { HYPERLINK "http://www.example.com" } I am merging to HTML email. I have been unable to get this to successfully work after saving. This is a

With a Word ContentControl DatePicker how do i get the value?

泄露秘密 提交于 2019-11-28 09:05:25
问题 I have a ContentControl that is a DatePicker in a word document. I'm trying to use it to populate some value in a code behind but I cant seem to get the value out of it. Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, _ Cancel As Boolean) None of the properties on ContentControl are close to .Value or .Text. I have seen other content controls use: ContentControl.DropdownListEntries(1).Text ContentControl.DropdownListEntries(1).Value This, as expected for a

Unable to use existing paragraph styles in Open Xml

不羁的心 提交于 2019-11-27 16:19:17
I'm working on an export of an HTML file to a Open XML wordfile. If in the HTML <h1> is used, I want to add a Heading1 style to that part. But somehow when I open the document in Microsoft Word 2010, the Style isn't applied. If I open the created document in Libre Office, there is some style applied. I also defined some styles myself, and if I use one of those styles, everything went well in Word and Libre Office. I opened the Open XML SDK 2.5 Productivity Tool for Microsoft Office and when I look in the example code it provides, it suggests: ParagraphStyleId paragraphStyleId1 = new