word-vba

How to access a Word public variable in Excel VBA

荒凉一梦 提交于 2019-12-08 15:55:54
问题 I'm trying to automate some report generation where Excel VBA is doing all the work. My employer has a standardized set of templates of which all documents are supposed to be generated from. I need to populate one of these templates from Excel VBA. The Word templates utilize VBA extensively. This is (some of) my Excel VBA code: Sub GenerateReport() ' (Tables, InputDataObj) ' code generating the WordApp object (works!) WordApp.Documents.Add Template:="Brev.dot" ' Getting user information from

Find all strings within a string

会有一股神秘感。 提交于 2019-12-08 15:04:56
问题 I get StrTxt as html string by http request response text. I want to find all occurrences of '"string"' in the StrTxt. Something like this. for each string in StrTxt StrTxt = "all matched strings from StrTxt" do something StrTxt. Edit This is tagged as possible duplicate but it's not. How to loop through each word in a word document - VBA Macro explains how to find string in document and not string. It is just simple. How to find all strings withing strings? Isn't my title explains everything

Deleting Empty Paragraphs in Word Using VBA: Not All Empty Paragraphs Deleted

陌路散爱 提交于 2019-12-08 13:54:33
问题 I wrote a macro to delete all the empty paragraphs in my document, but it exhibits weird behavior: If there are a number of empty paragraphs at the very end of the document, about half of them are deleted. Repeatedly running the macro gradually eliminates the empty paragraphs until only one empty paragraph remains. Even if there is a boundary condition so that I need a line of code to delete the last paragraph, but I still don't understand why only half of the empty paragraphs at the end are

VBA code in word to import excel data

北城余情 提交于 2019-12-08 13:34:51
问题 I have an excel file with data in column A - ZZ, I am needing to import columns E,F,G,I into a table within a word document. I don't want to use mail merge as I want the data all within the same table within word. Can anyone give me any pointers? I have been looking for a while and testing code unsuccessfully. Sub Macro1() Dim rowCount2 As Long, shtSrc As Worksheet Dim shtDest As Worksheet Dim rng2 As Range Set shtSrc = Sheets("Roadmap") Set shtDest = ActiveDocument.Range(1) rowCount2 =

Word VBA Script for Shannon entropy of the alphabetic characters

我们两清 提交于 2019-12-08 10:37:41
问题 I have a document and want to take the Shannon entropy of each character in Word VBA. I have already calculated the Shannon entropy for each character but don't know how I would put this information in a word VBA and sum it up. Shannon entropy for each character (source: bearcave.com) Space,0.1859 A 0.0856 B,0.0139 C,0.0279 D,0.0378 E,0.1304 F,0.0289 G,0.0199 H,0.0528 I,0.0627 J,0.0013 K,0.0042 L,0.0339 M,0.0249 N,0.0707 O,0.0797 P,0.0199 Q,0.0012 R,0.0677 S,0.0607 T,0.1045 U,0.0249 V,0.0092

From a VBA Excel file open a word template, enter a number and print

六眼飞鱼酱① 提交于 2019-12-08 06:32:13
问题 So far I've had great sucess with questions/solutions and obtaining lots of knowledge in excel vba but once again i'm stuck on a different kind of problem. Here is my scenario: We do samples that are serialized and tracked in an excel vba spreadsheet. Multiple lines can be added and they are identified by the serial number. Each sample sent contains a information sheet that is also serialized. Right now once we enter the serial number into excel, we have to manually enter the serial number

Change default filename in SaveAs Dialog

风流意气都作罢 提交于 2019-12-08 06:17:35
问题 I am trying to change the proposed filename within the " Save As "-Dialog based on the content of a Content Control. My understanding was that Word is proposing the Document Property „ Title “ within the SaveAs Dialog. Within an empty Document I created a Content Control (Text only) and put the following code in "This Document". Private Sub Document_ContentControlOnExit(ByVal objCC As ContentControl, _ Cancel As Boolean) ActiveDocument.BuiltInDocumentProperties("Title") = objCC.Range.Text End

How to open a browser window through Word using VBA with set height, width, and no menu bar

吃可爱长大的小学妹 提交于 2019-12-08 05:40:26
问题 I basically want to open a browser window from Word using VBA that does the same as javascipt: window.open ("http://www.google.com","mywindow","menubar=0,resizable=0,width=350,height=250"); 回答1: How about something like: Sub window_Open(strLocation As String, Menubar As Boolean, height As Long, width As Long, resizable As Boolean) With CreateObject("InternetExplorer.Application") .Visible = False .height = height .width = width .Menubar = Menubar .Visible = True .resizable = resizable

VBA Solution for quick rename of active office document file (Word, Excel, PowerPoint)

不想你离开。 提交于 2019-12-08 03:47:29
问题 File rename is often requires while working on Microsoft Office Suite applications (Word, Excel, PowerPoint). Usually “Files > Save as” allows rename the file but it also create duplication since the original file remain there and there is no simultaneous options to delete the original file. Although this option is currently in practice but for quick and convenient rename without any duplication of same file the current available option is not adequate. Close the file, remember its name and

VBA: Reading excel data into word

元气小坏坏 提交于 2019-12-08 02:18:15
问题 I am making a simple form that extract the data from my excel sheet, such as name, date of birth, and address. And inserting them into my word form, I am doing 20-30 sheets everytime, so I think it might be able to save the copying & pasting time. I tried to follow this tutorial: http://www.makeuseof.com/tag/integrate-excel-data-word-document/ And created a button with a simple label named m_name , for member's name. But it tells me Compile error: User-defined type not defined . And flaged on