天道酬勤,学无止境

ms-word

How to change format of current paragraph without using Selection

I have the code below without using Selection. Sub Format paragraph() Dim wdDoc As Document With wdDoc.Range.Find .Font.Size = 12 .Text = "?" .Execute End With End Sub When the character with font size = 12 is found, how can I change the format of the current paragraph? for example: wdDoc.Paragraph(current).Font.Size = 14 wdDoc.Paragraph(current).Font.Color = wdBlue Thanks for any help.

2021-09-25 17:34:38    分类:问答    vba   ms-word

Replacing all occurrences of a string in a Word file by an hyperlink

I have to create a Powershell script that reads a Word file (.docx) and replaces strings by hyperlinks. So far, based on this script, I can replace all occurrences of a string by another string easily. With that script, I can look for a string and replace it by an hyperlink. However, only the first occurrence is replaced. Here's my understanding of the problem so far : The first script uses the ReplaceWith and Replace=wdReplaceAll parameters of the Execute function of the Find Interface. The issue is that ReplaceWith expects a String and not an Hyperlink object. The second script doesn't

2021-09-25 06:52:43    分类:问答    vba   powershell   ms-word

How to change font size of non-English words?

In a Word 2007 document, I manually select a sentence containing both English & Bengali words of multiple font size. When I enter some numeric value in Font size list-box in the panel and press Enter, the whole sentence font size is changed (including Bengali words). When I select the same sentence in a Word-VBA macro and in final line try Selection.font.Size=8 only English words' font size gets changed. I tried to loop through each character, but got the same result. I need to stick to Word-VBA as it is part of a web scraping program using Chrome web-driver Selenium. I tried a simple macro in

2021-09-24 08:17:57    分类:问答    vba   fonts   ms-word   non-english

通过文字自动化服务运行后,表格文本会获得额外的间距(Table text gets extra spacing after running through word automation services)

问题 我正在从一堆模板文档生成一个文档,此外我正在添加一些表格作为 html altChunk s(因为它比尝试使用 OpenXML 创建表格要容易得多)。 这一切都很好,给了我想要的结果。 但是,由于某些版本的 Word(特别是在 Mac 上)处理altChunk的方式altChunk一些缺陷,并且无法自动更新 TOC,我们决定将其设置为通过 Sharepoint 中的 Word 自动化服务运行我们的报告。 所以,我们生成文档如前,然后让它通过Word自动化的扁平化altChunk成一个单一的文件和更新目录。 这解决了我们所有的兼容性问题并更新了我们的 TOC,但不幸的是,有一个副作用。 我们的表格现在在文本上方和下方增加了空间,使表格比以前长得多。 这在以前不是问题,即使我们打开我们的文档并在 Word 中重新保存(因此扁平化所有altChunk s),所以这似乎是一个特定于单词自动化的问题。 有没有人见过这个? 有没有办法,使用包含表格的 HTML altChunk来强制单词自动化不要弄乱我的表格? 编辑:如果我在 Word 中选择有问题的表格并选择主页选项卡“行和段落间距”,然后我可以选择“删除段落后的空格”以将表格折叠回应有的状态。 因此,Word Automation Services 似乎希望在表格中的段落之后添加空格,而 Word 本身却没有。 有人知道如何阻止吗?

2021-09-24 07:04:49    分类:技术分享    ms-word   sharepoint-2013   openxml   docx   word-automation-service

使用 VBScript 删除 MS Word 宏(Remove MS Word macro using VBScript)

问题 我想使用 VBScript 从 MS Word 模板中删除所有 vba 模块。 我写了以下脚本。 const wdDoNotSaveChanges = 0 WScript.Echo "starting Word..." Dim oApplication, doc Set oApplication = CreateObject("Word.Application") WScript.Echo "opening template..." oApplication.Documents.Open "path\to\test.dot" Set doc = oApplication.ActiveDocument Dim comp, components Set components = oApplication.ActiveDocument.VBProject.VBComponents For Each comp In components components.Remove comp Next WScript.Echo "exiting..." doc.close wdDoNotSaveChanges oApplication.Quit wdDoNotSaveChanges 在 Word 中的 VBA 模块中运行类似的代码时,这test.vbs(14, 2) Microsoft

2021-09-24 06:44:25    分类:技术分享    vba   vbscript   ms-word

Is it possible to refresh fields of a word document with Office.js?

I have word documents with fields that display the value of custom document properties as such: `{ DOCPROPERTY example \* MERGEFORMAT }` Whenever my custom property is modified, in order for the changes to be displayed in my document, I need to select the field(s) and right-click -> update them. I was wondering if office.js had anything that would help me automatically update fields in my document.

2021-09-24 06:14:33    分类:问答    ms-word   office-js   office-addins   word-field

Using a macro to create conditional formatting in Word as per Excel

I have an Excel doc that has conditional formatting that changes the background colour of a cell, dependant upon the specific [dropdown] text that is selected. E.g Yes, changes cell background to Green, No to Red, Unknown to Yellow and Not applicable to Grey. All easy stuff. I then need to mailmerge to a Word doc to populate the Word doc with the Excel table - the Word doc also has other non-excel related text. As conditional formatting of the cells does not come across, I have used the under noted code in a macro to change the background colour in Word. It runs, but seems after the first loop

2021-09-24 05:24:32    分类:问答    vba   ms-word   conditional

从上一个标题获取标题编号(Get heading number from previous heading)

问题 这个由 Paul Beverley 编写的 Word 宏向文档添加了注释并插入了页码和行号。 Sub CommentAdd() ' Version 20.02.12 ' Add a comment ' Ctrl-Alt-# attrib1 = "PB: " attrib2 = "PB: " postText = "" keepPaneOpen = False addPageNum1 = True addLineNum1 = True addPageNum2 = True addLineNum2 = True highlightTheText = False textHighlightColour = wdYellow colourTheText = False textColour = wdColorBlue Set rng = Selection.Range rng.Collapse wdCollapseEnd rng.MoveEnd , 1 pageNum = rng.Information(wdActiveEndAdjustedPageNumber) ' <<<<<----- This line lineNum = rng.Information(wdFirstCharacterLineNumber) If Selection.End <> Selection

2021-09-24 03:54:02    分类:技术分享    vba   ms-word

Conditional Formatting in Microsoft Word 2016 Table Cells

I have a table and it is for a test plan I am doing for a project, there is a column at the end of the table where the 2 values in it will be Y (passed the criteria) or N (didn't pass the criteria) Is there a way in Microsoft Word to change the colour of the text on the row with the value of N at the end, this makes it easier to spot the places where it failed the criteria. I know you can do the find and replace method but I was wondering if there was a way to do this automatically so when the user enters N it changes the whole row to red and when they enter Y it changes it back to normal

2021-09-24 03:35:25    分类:问答    ms-word   ms-office   conditional-formatting

测试 TOC 域代码返回的错误(test for error returned by TOC field code)

问题 在创建图表之前,我试图测试是否存在任何“图表标题”。 我有一行有效的代码: {IF {TOC \h \z \c "Figure"} = {TOC \h \z \c "blarghel"} " No table" "Entries exist"} (字段代码,当然),其中“blarghel”是一个故意的假人。 我以为我曾经能够(在 Word 2003 中)引用返回的错误字符串,对于 WORD 2010 来说是 {IF {TOC \h \z \c "Figure"} = "No table of figures entries found." " No table" "Entries exist"} 但这总是返回“IF”测试的失败条件。 我没有看到任何“ISERROR”类型的域代码,也无法弄清楚 TOC 域代码实际返回的是什么。 有任何想法吗? (是的,通常我会用字段代码替换第二个条件以返回图表表:-)) 谢谢。 卡尔 回答1 我认为您需要在 Word 2010 中的错误消息之前添加一个额外的段落标记。自 Word 2003 以来,这可能发生了变化 - 我没有检查过: {IF {TOC \h \z \c "Figure"} = " 未找到图表条目表。" “无表”“条目存在”}

2021-09-24 02:58:08    分类:技术分享    ms-word   word-2010   fieldcodes