word-vba

Moving down a row in a Word table containing multi-paragraph cells

╄→гoц情女王★ 提交于 2019-12-02 04:59:09
问题 How can I reliably move down the rows in a Word table? Here's the structure of the table. Note that the first and second columns can both have multiple lines and paragraphs. Rule ID 1 Logic Date must be equal to or greater than 01-Jan-2012 Discrepancy Date is before 01-Jan-2012 message Test case 1.1 Create form where Date is before 01-Jan-2012 Verify discrepancy message appears. Print form. Test case 1.2 Create form where Date is equal to 01-Jan-2012. Verify no discrepancy message appears.

Add Shape at the end of the document

我的梦境 提交于 2019-12-02 04:43:15
I'm trying to add a shape specifically a textbox. I need to add it after all the contents I added through vba. I can't seem to figure how to do it since adding the shape needs the exact measurement of the Left and Top parameters. Dim shpActual Dim pos, PtsToInches set shpActual = Selection.Shapes.AddTextbox(msoTextOrientationHorizontal, 92, PtsToInches, 437.4, 69) pos = Selection.Range.Informatio(wdVerticalPositionRelativeToPage) PtsToInches = pos / 72 You can use the .RelativeVerticalPosition to position the shape after you insert the shape. See this example Sub Sample() Dim objShape As Shape

Sharing VBA modules across MS Office Applications

瘦欲@ 提交于 2019-12-02 04:04:33
I have a substantial bank of VBA modules written in an Excel 2010 add-in. Some of these are specific to Excel, but many are more general. For example one takes a part number and re-formats it; another contains a Case Select function to find a file in a network drive. I want to use the common functions in Word and Outlook. I could copy and paste from the Excel to Word add-ins, but this makes it difficult to keep my code up to date - when I make an edit in one application, I must remember to copy to all the others. My question is, is there any means of writing common code in one place (e.g. in

Extract data from content controls in Word to Excel

≡放荡痞女 提交于 2019-12-02 03:50:51
I have a Word document that is "form-fillable", i.e. it has content control objects in it such as rich text and date picker content controls. I am looking to extract the data from specific fields into Excel. For example, every form has the project title, start date, and manager. I would like 1 row for that form with those three pieces of data. Eventually this will need to be done for a few hundred of these forms every few months, but for now I'd like to just start with one. I envision having a button on the Excel sheet that will run VBA code to pull the data from the Word document, and

VBA macro: replace text in word file in all sub folders

僤鯓⒐⒋嵵緔 提交于 2019-12-02 02:55:17
I am putting together a VBA macro that: 1.reads a folder 2.creates a collection of all its subfolders 3.loops through all the subfolders and find any word document ending in .doc 4.in each .doc file: replace a bit of text and save then close the documents. This macro doesn't work correctly: it doesn't replace the text in any word documents in the subfolders. It doesn't actual open any word document, I am unsure wether it should open each word doc one after another or if it runs in the background. Sub DoLangesNow() Dim file Dim path As String Dim strFolder As String Dim strSubFolder As String

Moving down a row in a Word table containing multi-paragraph cells

我怕爱的太早我们不能终老 提交于 2019-12-02 02:18:52
How can I reliably move down the rows in a Word table? Here's the structure of the table. Note that the first and second columns can both have multiple lines and paragraphs. Rule ID 1 Logic Date must be equal to or greater than 01-Jan-2012 Discrepancy Date is before 01-Jan-2012 message Test case 1.1 Create form where Date is before 01-Jan-2012 Verify discrepancy message appears. Print form. Test case 1.2 Create form where Date is equal to 01-Jan-2012. Verify no discrepancy message appears. Print form. Test case 1.3 Create form where Date is after 01-Jan-2012. Verify no discrepancy message

Iterating XML nodes using VBA

女生的网名这么多〃 提交于 2019-12-02 01:24:58
Note:- It just might be a iterating XML nodes using VBA question. Please look at the bottom of this question. It would be good If we can iterate without using MSXML2.DOMDocument I see the this question which answers part of my question on how to retrieve the CustomXMLPart. However, I am not able to iterate through the Xml. That way, this might not be specific to CustomXmlPart, It just might be a iterating XML using VBA question. Following is the XML I have in my CustomXMLPart. <Items> <Item1>Item1</Item1> <Item2>Item2</Item2> <Item3>Item3</Item3> </Items> This is how I add the above XML as

Delete doc when macro finishes

守給你的承諾、 提交于 2019-12-02 01:07:39
I have a Word 2007 docm file that I send to users as an email attachment to let them update files. The macros download files from a server and install them correctly - as opposed to sending the files as email attachments and trusting users to get it right. I'd use a VBScript file instead, but I'm not allowed to send that in an email. I would like to delete this document from the user's computer when the macro finishes. But the doc is still open and the macro still running when it hits any Kill or FSO.FileDelete command. edit: found a way to have the Word macro create and launch a VBScript,

What's wrong with calling Application.GetOpenFilename method in Word VBA?

删除回忆录丶 提交于 2019-12-01 23:57:44
Namely, I called the following snippet in a button handler: TextBox1.Text = Application.GetOpenFilename("All files (*.*),*.*", _ 1, "Open the Raw Data Files", , False) If TextBox1.Text = "False" Then TextBox1.Text = "" The error said: "Compiler error: Method or data member not found" Thanks in advance! There is no Application.GetOpenFilename in Word. You need to use FileDialog instead. Here's a quick example: Private Sub CommandButton1_Click() Dim s As Variant Dim Res As Integer Dim dlgSaveAs As FileDialog Set dlgSaveAs = Application.FileDialog( _ FileDialogType:=msoFileDialogSaveAs) Res =

Word 2007 VBA - Making some text BOLD & other ITALIC

守給你的承諾、 提交于 2019-12-01 23:30:08
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 & UPPER CASE, whilst making the "ccc ddd eee" data into ITALICS ? ": goes to AAA BBB of ccc ddd eee - "