word-vba

Insert checkbox caption in Word document

空扰寡人 提交于 2019-12-24 10:49:53
问题 The following inserts an autotext element in a Word document NormalTemplate.AutoTextEntries("ap_pressurefilter").Insert _ Where:=Selection.Range, RichText:=True but how do I insert the caption of a checkbox (checkbox1.Caption) in the document? Thanks. 回答1: Solved it! Selection.Text = checkbox.Caption 来源: https://stackoverflow.com/questions/14982244/insert-checkbox-caption-in-word-document

How can I open Excel from another Office Application without setting references?

浪子不回头ぞ 提交于 2019-12-24 10:49:06
问题 From Word and Outlook, I'm trying to open open Excel using GetObject method but I need to set the references first. I receive "Compile error: User-defined type not defined". In order to manually fix this, I need to go to Tools>References>Microsoft Excel XX.X Object Library. Is there a way to not have to do the manual step of setting the reference? I access the same files from different sessions (local session, citrix, VM ware) that have different versions of Excel. https://docs.microsoft.com

MS Word VBA Find and Loop (NOT Replace)

我是研究僧i 提交于 2019-12-24 10:36:29
问题 Sorry for the fundamental question but I am a LONGtime Access VBA developer who is getting my butt kicked by Word. I am building a solution for someone who uses a Legal Case Management System with a specific numbering scheme (aaa-aaa-##-##-###). I need to search a document for hyphens and then grab the whole paragraph where a hyphen is found. I then need to send the text from that paragraph to a separate function which parses out the file number from the paragraph (this function already works

word-vba macro unable to change font size of non English words

筅森魡賤 提交于 2019-12-24 10:17:46
问题 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 successfully (including Bengali words). However when I select the same sentence in VBA word macro and in final line try Selection.font.Size=8 only English words' font size gets changed. What is the problem? I also tried to loop through each characters, but

Sorting strings in word macro

喜夏-厌秋 提交于 2019-12-24 09:03:44
问题 I need help with writing a function which will take an array of strings and sort this into a new array of strings based on only the number characters in the strings (ascending)? say I have the following array of strings: "abc53ddd", "2zzz2yyy", "14" I will need them listed as "14", "2zzz2yyy" and "abc53ddd" as the number characters in the string are 14, 22 and 53. I can strip the string into the number portions and sort the array but I can't recover the remaining characters to list them back

Changing paragraph alignment of word document through VBA

耗尽温柔 提交于 2019-12-24 06:49:30
问题 I Have excel workbook which maintains data of my customers Like address & Due amount. I am writing a VBA code in excel which will generate letter to each of the customer for the due amounts. I cannot use mailmerge because of the complexity of the letter. I am using following codes to add paragraphs Set wrdApp = CreateObject("Word.Application") wrdApp.Visible = True Set wrdDoc = wrdApp.Documents.Add wrdDoc.content.InsertAfter "----------" wrdDoc.content.InsertParagraphAfter Now I need to

Changing paragraph alignment of word document through VBA

左心房为你撑大大i 提交于 2019-12-24 06:49:16
问题 I Have excel workbook which maintains data of my customers Like address & Due amount. I am writing a VBA code in excel which will generate letter to each of the customer for the due amounts. I cannot use mailmerge because of the complexity of the letter. I am using following codes to add paragraphs Set wrdApp = CreateObject("Word.Application") wrdApp.Visible = True Set wrdDoc = wrdApp.Documents.Add wrdDoc.content.InsertAfter "----------" wrdDoc.content.InsertParagraphAfter Now I need to

Word VBA, Select whole document minus first page

天大地大妈咪最大 提交于 2019-12-24 04:43:29
问题 I know you can select the whole document like so oWord.oDoc.ActiveWindow.Selection.WholeStory What would be the syntax to select the whole document minus the first page? Context: Excel runs all the code and outputs ranges direct to word to build a report. Reports can be any number of pages and the amount of pages is not known. This code would run as the last piece so document would be built by this point. 回答1: The following code selects everything from the second page onward: Dim startRan As

How to apply macro at end of every heading in MS Word?

眉间皱痕 提交于 2019-12-24 02:40:25
问题 I have a document with various headings (so not necessarily Heading 1 or Heading 2 - but all types of headings). What I'm trying to do is write a macro that will, for example, delete 2 spaces at the end of each heading. For example, we have This is a heading At the end of heading, I will do: Selection.Delete Unit:=wdCharacters, Count:=2 I need this to be applied at the end of each heading. Does anyone know how to do this? 回答1: Goto first heading: Selection.GoTo What:=wdGoToHeading,Which:

Event change of table in Word

北慕城南 提交于 2019-12-24 01:52:49
问题 Private Sub Document_Change(ByVal Target As Range) Set table = ActiveDocument.Tables(1) If Not Intersect(table, Target) Is Nothing Then Target.AutoFormat ApplyColor: Red End If End Sub I have the following code, but it does not seem to work in VBA Word. Can anyone help me out? 回答1: I suppose that you copied the code from Excel VBA and tried to rebuild it a bit. There are a few differences between Excel and Word VBA. Intersect does not exist in Word VBA. DocumentChange event in Word works