word-vba

Copy Disjointed Cells from Excel Table to Word Table Using VBA

假装没事ソ 提交于 2019-12-11 06:26:49
问题 I'm trying to copy disjointed cells from an excel document to the cursor location in word and use my predefined table style. The disjoint copy/paste works nicely in excel when I just copy and paste into the current active worksheet, but as soon as I try to execute the same copy/paste from word, it ends up copying the entire table from top-left all the way to bottom-right, instead of doing the disjointed copy/paste. I know there are some differences between the individual function from excel

MS Word VBA - Replace text with matching Mail Merge Field

六月ゝ 毕业季﹏ 提交于 2019-12-11 06:05:07
问题 I would like to create a macro in MS Word that when run searches the document for text that appears in the body of the document that matches the mail merge field name. Once identified it would change the text in the document to the actual matching mail merge field name. For example, if there was a mail merge field named "project_date" and in the Word document there was the text "project_date" the macro would turn the text into the actual mail merge field "project_date". Ideally, the macro

Dealing with space in file path in VBA

ぐ巨炮叔叔 提交于 2019-12-11 05:56:34
问题 I have the below VBA code that I'm trying to run in cmd . There is a space in the path and I'm using quotes to deal with that. strWot2Shell = """C:\Program Files\gs\gs9.20\bin\gswin64.exe""" & " -dBATCH -dNOPAUSE -sDEVICE=png16m -r600 -sOutputFile=" & Chr(34) & ripDirectory & "\LagerRiskRapport%01d.png" & Chr(34) & " " & Chr(34) & filePathAndFileName & Chr(34) strWot2Shell = Replace(strWot2Shell, "\", "/") strWot2Shell2 = "cmd.exe /S /C " & strWot2Shell wsh.Run strWot2Shell2, windowStyle,

VBA MS Word - Insert all mail merge fields into Word doc at once

房东的猫 提交于 2019-12-11 05:37:36
问题 Currently MS Word only allows for the insertion of 1 mail merge field at a time. I am looking for a VBA code that would allow me to insert all merge fields into a Word doc at once and/or a code that would input a mail merge field where the name of the same mail merge text appears in the doc. For the second possibility I have found the following code that allows the user to convert text that matches a mail merge name into a mail merge field one at a time ( http://apsona.com/blog/how-to-quickly

How to get the position of submatches in VBA?

断了今生、忘了曾经 提交于 2019-12-11 04:47:11
问题 I need to get the index position value of submatched string. As per documentation, I have read through this Regular expression and got to know FirstIndex property to get the position of matched string. But this works only for one dimensional matched string. I couldn't apply FirstIndex for submatches. Pls refer sample matches I tried this format, Dim myRegExp As Object, match As MatchCollection Dim matched As String Set myRegExp = CreateObject("VBScript.RegExp") myRegExp.pattern = find If

Inserting a picture at a bookmark (OR how to tell if any list box items have been selected)

谁说胖子不能爱 提交于 2019-12-11 04:21:59
问题 I'm new to VBA and still struggling a lot. I have a list object on a useform that is populated with the file-names of the contents of the relative ".\logos\" directory. I want to insert the picture at a bookmark named bmLogo , but the code I've written (see below) doesn't do the trick. If ListLogo <> Null Then ActiveDocument.Bookmarks("bmLogo").Range _ .InlineShapes.AddPicture FileName:=ThisDocument.Path & "\logos\" & ListLogo End If Any tips? Also, if I could set a height and have the image

Is WINWORD.EXE running?

放肆的年华 提交于 2019-12-11 04:11:01
问题 I want to know whether WINWORD.EXE is running when I open a Word document embedded in Excel. If it is not already running then I want to use objWord.Quit . It's possible the user is working in Word and I don't want to interfere with that, so in that case objWord.Quit should not be executed. I have this -sniped- code: 'Variable declaration Dim objWord As Word.Application Dim objDoc As Word.Document objWord is being instantiated like this: ActiveSheet.OLEObjects(P).Activate Set objWord =

Inserting symbols into Office Ribbon XML controls

南楼画角 提交于 2019-12-11 03:49:13
问题 I am building a ribbon tab for Word 2010 from scratch using XML stored within a Word template's customUI14.xml file. I am creating buttons that when clicked insert the text for various symbols (the euro, section mark, etc.) The code for inserting the symbols works fine, but I cannot get the labels of the XML controls to display these symbols. For example, I tried this to display a euro symbol: <group id="rxGroupSymbols" label="Symbols"> <button id="rxbtnEuro" label="&#128;" size="normal"

Word 2010 VBA Macro: loop to end of document

给你一囗甜甜゛ 提交于 2019-12-11 03:27:38
问题 I have recorded a simple macro to find the word "Quantity", go to the end of that line and insert a carriage return. I need to repeat it to the end of the document and quit, or else I'll have an infinite loop. The code: Selection.Find.ClearFormatting With Selection.Find .Text = "Quantity:" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = True .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With

Macro to insert a cross reference based on selection

纵饮孤独 提交于 2019-12-11 02:29:01
问题 I currently work for a company which uses a set house-style for its documents. This includes multi-levelled numbered headings built in to our Word template. I.e. Heading 1 1.1 Heading 2 1.1.1 Heading 3 etc... A large part of our current task involves adding in cross references to other parts in the document. This can be quite time consuming when the doc runs to several hundred pages with around 10 references on each page. What I was wondering was if a macro could be set up to add a x-ref