ms-word

Open two existing word files from excel

痴心易碎 提交于 2020-03-25 18:32:07
问题 Hi I'm trying to write code to use excel to work with two existing word documents but I keep getting OLE errors. This is just the start but it keeps crashing. What am I doing wrong? Sub BoQtoWord() Dim Word As Object Dim WordDoc As Object Dim WordDoc1 As Object Dim StdSpec As String Dim NewSpec As String StdSpec = Application.GetOpenFilename() Set Word = CreateObject("Word.Application") Set WordDoc = Word.Documents.Open(StdSpec) Sheet1.Range ("A1").Value = StdSpec NewSpec = Application

Matching subset of data

不羁的心 提交于 2020-03-25 13:48:54
问题 I am populating ActiveX control labels with a subset of Excel data in VBA. My code previously worked for the entire Excel workbook, but once I changed my code to only reference a subset of the data, the incorrect data is being entered. Here is a snapshot of example data. In my code, Column 6= CY and Column 7 = FY. The code is currently populating my labels with the headers of Column 6 and 7 rather than the values of 'active' or 'merged' projects. As mentioned, I am not receiving any error

Getting an error trying to insert field in a Word table cell

蓝咒 提交于 2020-03-24 00:16:39
问题 I create a formfield (textinput), and when I go to name it I get: 91 Object variable or With block variable not set There are dozens of other places in this macro where I do the same exact thing and it works fine. Here is the code: Private Sub IRPMs() Dim objCon As New ADODB.Connection Dim rs As New ADODB.Recordset Dim i, j, k As Integer Dim tmpField As FormField Dim strOut As String Set doc = ActiveDocument i = 0 j = 1 k = 0 Call grabInfo strFieldName(1) = "Property: " strFieldName(2) =

Table Cross-References in Bookdown with MS-Word Output?

大憨熊 提交于 2020-03-18 06:30:09
问题 How can I make table cross-references work in a bookdown document with all of the output formats pdf, docx, and html? Or maybe more specifically, how can I get table cross-references working for flextables ? Below is a minimal working example. The second table, using kable() , gets me almost all the way there. The problem is that the table rendering in docx output is completely unusable (not in this MWE, but in my actual use-case). I considered creating the table conditionally, using

How to change the text of a form field text box on entry of that text box

孤街浪徒 提交于 2020-03-12 06:08:17
问题 I am trying to change the text of a form field text box when it is entered into. I selected to run a macro on entry, but I can't seem to change it dynamically for all my fields using that macro. There are hundreds of fields which are removed and added dynamically, so setting a bookmark for every one of them is not an option as specified in this question answer MS Word Document Form - Check Value of Text Form Field on Exit Is there any way to access the form field on entry so I can change it

How to change the text of a form field text box on entry of that text box

杀马特。学长 韩版系。学妹 提交于 2020-03-12 06:08:00
问题 I am trying to change the text of a form field text box when it is entered into. I selected to run a macro on entry, but I can't seem to change it dynamically for all my fields using that macro. There are hundreds of fields which are removed and added dynamically, so setting a bookmark for every one of them is not an option as specified in this question answer MS Word Document Form - Check Value of Text Form Field on Exit Is there any way to access the form field on entry so I can change it

RegEx find string containing numbers with one space, two spaces or no space at all followed by / and four numbers

匆匆过客 提交于 2020-03-05 00:27:16
问题 I need to use RegEx to find a string in Word document. The string contains numbers{1;5} with one space, two spaces or no space at all followed by / and four numbers{4} which denotes a year in which the document was created. The strings I need to find are like these: 45 /2017 125 /2019 1245 /2018 12577 /2019 37589 /2017 but sometimes there is no space in between: 45/2017 125/2019 1245/2018 12577/2019 37589/2017 and sometimes there is two spaces: 45 /2017 125 /2019 1245 /2018 12577 /2019 37589

RegEx find string containing numbers with one space, two spaces or no space at all followed by / and four numbers

試著忘記壹切 提交于 2020-03-05 00:26:29
问题 I need to use RegEx to find a string in Word document. The string contains numbers{1;5} with one space, two spaces or no space at all followed by / and four numbers{4} which denotes a year in which the document was created. The strings I need to find are like these: 45 /2017 125 /2019 1245 /2018 12577 /2019 37589 /2017 but sometimes there is no space in between: 45/2017 125/2019 1245/2018 12577/2019 37589/2017 and sometimes there is two spaces: 45 /2017 125 /2019 1245 /2018 12577 /2019 37589

Document_New event on launching Word

有些话、适合烂在心里 提交于 2020-03-03 08:13:15
问题 I have a VBA addin which I want to run every time someone opens a document. It's working fine for opening existing documents (AutoOpen) and creating new documents from the File > New menu (AutoNew) but when I just open Word up for the first time, neither of these events are firing. The only event I can seem to hook into is the AutoExec event and this is not great as the document doesn't exist yet so ActiveWindow is null. Can anyone help? Sub AutoNew MsgBox "New" End Sub Sub AutoOpen MsgBox

Find unknown name and surname in opened Word document, copy it and paste into the cell A12 in excel .activesheet with excel VBA

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-25 04:02:50
问题 Hello Stackoverflow community. My goal is to write a macro that finds unknown name (or both names written like so "Firstname Secondname") and surname (or both surnames written like so "Firstsurname-Secondsurname") in previously opened/active Word document - there will be only one Word document opened on the computer at the time. I want to find and copy the name and surname from point 2. Next the macro should copy this name and paste it into the cell A12 in excel"s .activesheet. Only one excel