word-vba

User selects item from drop down box, clicks button, and the selected item populates the last row of a table

只愿长相守 提交于 2019-12-11 17:25:57
问题 In Microsoft word, I have a 3x3 table, a button, and a drop down list. When I press the button, I want the last row of the first column to be filled with the selected drop down list item. Then, add a row to the table below it. Currently, I can't even fill values into the table. ActiveDocument.Tables(15).Rows.Last.Cells.Value = "Hello" returns an error. What can I do? I managed to select the last row. ActiveDocument.Tables(15).Rows.Last.Select Now, I need to copy the current value from the

how to update table in word?

南楼画角 提交于 2019-12-11 17:06:42
问题 I am working on the bearing report. I have to copy and find the relevant bearing data from the excel file and paste it in the word table. I have figured out the codes to To go to the relavant location in the word file and paste some data in desired word document. Sub CreateNewWordDoc() Dim wrdApp As Word.Application Dim wrdDoc As Word.Document Dim i As Integer Dim arr(12) 'Bearing numbers I need to search arr(0) = "(249_L), 38,7 %" arr(1) = "(248_R), 38,7 %" arr(2) = "(249_M), 38,7 " arr(3) =

Set the count of the Rows and Columns are there in the embedded Excel object's height and wide

北慕城南 提交于 2019-12-11 17:00:28
问题 There is a MS-Word document. A Macro-Enabled Excel object was embedded. I need setting the embedded Excel object's Height and Width with count of the -respectively- Rows and Columns are there involved. As marked above picture with the red circles, it would be resizing by dragging with mouse. How can perform this resizing with a macro in the embedded Excel's module? Setting the Embedded object's height equal the count of Excel's Table Rows Setting the Embedded object's width equal the count of

Is it possible to create an 'input box' in VBA that can take a text selection with multiple lines as an input?

耗尽温柔 提交于 2019-12-11 15:26:35
问题 I am trying to create a macro that will filter out relevant information from some selected text (smaller than a page long). This information will then be used to fill out a MS-Word template. I have been opening the selected texts via a .txt file however I feel it will improve workflow if it were possible to copy & paste the selected text into some form of an input box. I have tried the following: Dim text As String text = InputBox("Enter selected text here:") This however only accepts a

Get paragraph no where txt is found, and move text to end of paragraph using Word 2010 vba

北城余情 提交于 2019-12-11 13:59:25
问题 I am trying to use VBA to move a rich text clause ("strText"), which appears at the beginning of various paragraphs, to the end of each paragraph where the clause appears, and thereafter to underline strText. I am a novice/hobbyist at vba programming, so please be gentle. I spent a few days on this before seeking help. Problems with my attempted coding (which appears below): I tried to assign to var "LparaNo" the number of the paragraph wherein the found text (strText) appears. But the number

VBA macros stop working after delete commandbutton only in docm from dotm

徘徊边缘 提交于 2019-12-11 13:58:10
问题 I have a problem very similar to this However the answer there is not very clear, and I tried recreating the commandbutton in question, and it did not work. Basically I have various sections within the template and for each section I have two buttons [Add sub-section] - (CommandButton1, CommandButton11, CommandButton111) [Done] - (CommandButton2, CommandButton21, CommandButton211) Everything works fine in the template. But if I create a new doc by either double clicking on the dotm or right

How to run a macro in Word after paste?

China☆狼群 提交于 2019-12-11 13:43:26
问题 How do I make Microsoft Word to run a macro every time every time the user paste text? I have recorded this macro: Sub AdjustFontSize() ' ' AdjustFontSize Macro ' Adjusts font size ' Selection.WholeStory Selection.Font.Size = 24 End Sub This changes the font size of everything in the document, and I want that to happen when the user is pasting text. 回答1: Try this code. Sub EditPaste() Selection.Paste Selection.WholeStory Selection.Font.Size = 24 End Sub EditPaste is an in-built command. You

To Add Header and Footer for many word documents?

痴心易碎 提交于 2019-12-11 12:39:58
问题 I have around 100 documents for which the header and footer need to be changed. Is there a possibility that i can do it just by writing a vba code or Macro in a word file? Is it possible to give a specific folder in a macro which ll add the header and footer for all the documents in that footer? the below code gives me error-5111 Private Sub Submit_Click() Call openAllfilesInALocation End Sub Sub openAllfilesInALocation() Dim i As Integer With Application.FileSearch .NewSearch .LookIn = "C:

How to delete blank rows or rows with spaces in a table that has one or more cells vertically merged?

蹲街弑〆低调 提交于 2019-12-11 11:02:07
问题 I need a vba script or help on what I'm writing in order not to exit the iteration when the table contains vertically and horizontally merged cells . Example of the table: --------- | | | <-- I don't want these rows deleted, they can be skipped |---| | | | | <-- I don't want these rows deleted, they can be skipped |---|---| | | | <-- this must be checked for emptiness in order to decide to delete or not |---|---| | | | <-- this must be checked for emptiness in order to decide to delete or not

How to iterate through text in the Word document by VB macro

核能气质少年 提交于 2019-12-11 10:23:31
问题 I wanted to count chars in the Word document by Macro I have no idea how to get reference two the text in visual basic macro and go through it. I would like to count how many of every char was in the document. For example in document: ABZBB A x 1 B x 3 Z x 1 Sub Macro1() Dim Box As Shape Set Box = ActiveDocument.Shapes.AddTextbox( _ Orientation:=msoTextOrientationHorizontal, _ Left:=50, Top:=50, Width:=200, Height:=400) Box.TextFrame.TextRange.Text = "My text comes this way" + Chr(10) Dim s