word-vba

Mimic word borders and shading option “apply to:” (text) with vba on an inline shape

旧巷老猫 提交于 2019-12-25 07:18:22
问题 I got a macro that has a table with the first row being the name for that table and all the subsequent rows are print screens pasted. What the macro does is that when a new print screen is pasted the image is resized to a specific size and is added a border of 050pt. I was asked that the border be applied to text: For example: What I did on the image was select the whole table with the little cross on the upper left hand corner, right click on the mouse, select "Borders & Shading" option and

How to switch to open Excel spreadsheet and work on it from Word with VBA

时光总嘲笑我的痴心妄想 提交于 2019-12-25 07:18:06
问题 I'm just trying to work on an open Excel spreadsheet from Word using VBA. I did a search on this and found the following code on How to get reference to an open Excel spreadsheet from Word?. The problem is, it seems to open a separate instance of Excel rather than the one I already have open, and then closes it after the action. How can I get the procedure to switch to the open Excel spreadsheet, perform the desired actions, and leave the spreadsheet open? Sub DoStuffWithExcelInWord() Dim xl

Word VBA - How to locate table cell containing Content Control?

你离开我真会死。 提交于 2019-12-25 07:04:23
问题 Objective I have a table in Word with 2 columns. The first has a drop down Content Control. I would like to populate the second column with text, the value of which depends on the option selected. Question Is it possible to get the cell reference that contains the clicked content control? I plan to use that to target the next column with the content. I'm thinking of something like this: Dim oCell As Cell oCel = 'some way to get cell reference containing the ContentControl here Dim curCellRow,

How to Copy/Paste text box from MS Word to Powerpoint slide?

最后都变了- 提交于 2019-12-25 06:22:00
问题 I am currently creating a document that will take the format and text from a MS Word document and paste it into a text box in a PowerPoint template. I have looked all over to see how this can be done and haven't found much. Any help would be much appreciated!! Public Sub CommandButton1_Click() Dim pptApp As Object Dim pptPres As String Dim folderPath, file As String folderPath = ActiveDocument.Path & Application.PathSeparator file = "Huntington_Template.pptx" pptApp.Visible = True pptApp

Display GAL in Excel to get Alias or Email Adress

僤鯓⒐⒋嵵緔 提交于 2019-12-25 04:27:35
问题 I am trying to make use of information found in THIS POST. I have 2 issues: the following line hangs indefinitly. FIXED--- its just hidden and has no task bar item, simple search told me how to bring to to the front strAddress = objWordApp.GetAddress(, strCode, False, 1, , , True, True).GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3A00001E") I need to return something I can use in a TO line, so an ALIAS or a full email address. I have tested this code in WORD and it works

Format number between markers as subscript

笑着哭i 提交于 2019-12-25 03:52:36
问题 I would like to find a number between two hashtags, delete the hashtags and format the number that was between the hashtags as subscript. Example: The text ##12## should be converted to 12 . Here is my code so far: Public Sub SubscriptText() With Selection.Find .ClearFormatting .Text = "##" .Replacement.ClearFormatting .Replacement.Text = "##" .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue End With End Sub This removes the ## , but how do I format the number as subscript?

Embed a file into a Word doc using VBA

我与影子孤独终老i 提交于 2019-12-25 03:49:19
问题 I am attempting to do this from Access 2010 using Word 2010. I have a WordDoc object and cannot find a way to embed a file. I tried starting from nothing using a bookmark: bmFile.Range.InsertFile "C:\Users\Me\Desktop\TestFile.xlsx" and that trew an error about the File being corrupted. I tried editing an existing embeded file using WordDoc.InlineShapes(1) but no properties were changable or relevant. Any ideas would be greatly appreciated. Thanks 回答1: From an existing file (as per your

MS Word VBA search text with find wildcards

百般思念 提交于 2019-12-25 03:28:36
问题 I need find these matches using "ms word find" with wildcards: {{1,000.00}} {{-125}} {{125-}} {{-1’100.00}} {{1’100.00-}} What should be the Selection.Find.Text for it? I tried this: [\{]{2}<*>[\}]{2} but it does not work for some words. This wildcard works almost exactly to what I need. I modified a bit to exclude Paragraph return ^13 [\{]{2}[!\}][!^13]@[\}]{2} However I have a problem matching a paragraph like this blabla {{2}} {{-2-}} blabla in this case it matches the whole paragraph ( {

Pull data from Access database to Word document

雨燕双飞 提交于 2019-12-25 01:55:21
问题 I am attempting to transfer data from an Access database into a Word document. I have performed a similar procedure using Excel and I need to code it using Access instead of Excel. The Excel code (for an analogy is this) Dim myworkbook As Excel.Workbook Set myworkbook = GetObject("C:\Users\jn\Desktop\trial.xlsm") then Dim excelstr As String Excelstr = Application.Range("A1:A100").Find("aword").Offset(0,1).Value I can't figure out how to do this with Access where I pull in data by finding a

Add specific Document to specific Word.Application

浪尽此生 提交于 2019-12-25 01:54:14
问题 May I assign the objDoc as a document of the ObjWord (after Set objDoc = oDoc.Object )? My code looks like this: 'Declaration Dim oDoc As OLEObject Dim objWord As Word.Application Dim objDoc As Word.Document Dim WS as Worksheet Dim strOdoc as String 'Initialization Set WS = Whorksheets("Sheet1") strOdoc = "WordDoc" Set objWord = New Word.Application 'Set objWord = GetObject(, "Word.Application") 'I need using GetObject to be able to made the activated OLEDocument, invisible. 'And Need Set