word-vba

Remove Paragraph Containg specific words(word vba)

ぃ、小莉子 提交于 2019-12-04 02:39:19
问题 I apologize for not having a program to show for my question, but I am in a serious pickle. I am looking for a vba word program that searches for specific words and deletes the paragraph those words are in. The aim of this exercise is to reduce the work load as I am using up to 1million plus words of text. EDIT I have created the program, could you please help me add a loop, to loop through the whole document? Sub SelectRangeBetween() Selection.HomeKey Unit:=wdStory 'Selection.TypeText Text:=

Word Automation: Write RTF text without going through clipboard

青春壹個敷衍的年華 提交于 2019-12-03 13:17:33
问题 I am trying to replace the current selection in Word (2003/2007) by some RTF string stored in a variable. Here is the current code: Clipboard.SetText(strRTFString, TextDataFormat.Rtf) oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0) Is there any way to do the same thing without going through the clipboard. Or is there any way to push the clipboard data to a safe place and restore it after? 回答1: Put the RTF in a file instead of the clipboard, then insert from the file, e.g.

Is it possible to access a parent property from a child that is in a collection?

情到浓时终转凉″ 提交于 2019-12-03 08:40:18
I've researched as much as I can and never found a definitive answer on this for VBA. This older StackOverflow post has almost everything, but not quite. VBA Classes - How to have a class hold additional classes Bottom line - I have a class CClock, which is parent to a Collection of CContacts, which is parent to a CContact. Is there any way to get at a property of the CClock class from a CContact. So something like Debug.Print , clsContact.Parent.Parent.Lawyer in the code below? I've tried setting the parents as I thought they should be but get the below error almost immediately at Set

Word Automation: Write RTF text without going through clipboard

眉间皱痕 提交于 2019-12-03 02:46:15
I am trying to replace the current selection in Word (2003/2007) by some RTF string stored in a variable. Here is the current code: Clipboard.SetText(strRTFString, TextDataFormat.Rtf) oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0) Is there any way to do the same thing without going through the clipboard. Or is there any way to push the clipboard data to a safe place and restore it after? Put the RTF in a file instead of the clipboard, then insert from the file, e.g. Selection.InsertFile FileName:="myfile.rtf", Range :="", _ ConfirmConversions:=False, Link:=False, Attachment:

How can I make sure my IE tab name is correct?

自闭症网瘾萝莉.ら 提交于 2019-12-02 18:46:25
问题 I'm using this code to grab the instance of Internet Explorer from word VBA and scraping some values from a webpage. I'm looping through 4 items (just in case, sometimes I've accidentally grabbed something called "Windows Explorer", which I have no idea what that is) to grab Internet Explorer. But before I begin scraping values, I want to make sure my tab name is "Overview - City". How can I test against the tab names? Dim shellWins As ShellWindows, IE As InternetExplorer Dim i As Long Set

Loop comparison macro

谁说胖子不能爱 提交于 2019-12-02 17:32:21
问题 I've done a text comparison macro using Word and I need to loop it so that it can compare between a few sets of documents. Any idea on how to do so? Here's my codes Dim template1 As Word.Document Dim spool1 As Word.Document Set template1 = Documents.Open("D:\Users\tmp4jj\Desktop\ComparisonTool\template1.docx") Set spool1 = Documents.Open("D:\Users\tmp4jj\Desktop\ComparisonTool\spool1.txt") Application.CompareDocuments OriginalDocument:=Documents("template1.docx") _ , RevisedDocument:

Quit Word.Application which opened in the child subrotine

瘦欲@ 提交于 2019-12-02 17:17:51
问题 We declared Word.Application object in the Pro1 child function below. As we need return the Word.Document object, that should be remained opened. How can I do quit the Word application in the parent SubRoutuine( test01 ) I need the objWord object which declared in Pro1 function will quit -quietly without prompt- after the test01 procedure running have end. I have two procedure below And perform this: Sub test01() WrdPDF objDoc:=Pro1 strPath:=ThisWorkbook.path & "\" & "rep.pdf" End Sub |

WORD VBA Count Word Occurrences [duplicate]

妖精的绣舞 提交于 2019-12-02 14:34:32
问题 This question already has an answer here : Word occurences in VBA: how to speed up (1 answer) Closed 6 months ago . i have a code below that is already working. However i need to simplify the code even further. The code i have below counts the word occurrences in a document. The code is as follows: Option Base 1 Sub arrangepara() Dim r As Range Set r = activedocument.Range If (r.Characters.Last.text = vbCr) Then r.End = r.End - 1 sortpara r End Sub Function sortpara(r As Range) Dim sWrd As

Preserve text format when sending the content of a word document as the body of an email,

久未见 提交于 2019-12-02 14:03:39
问题 I'm trying to send the content of a word document as the body of an outlook email, but it happens that the formats of the texts (Bold, color, etc) are lost after they are inserted into the email. I have also tried using the word document as an Envelop item, and it did preserve the original format but the .Display method does not work under such circumstances. Below are my codes bodi = wdDoc3.Content With wdApp.ActiveDocument .SaveAs ThisWorkbook.Path & "./Past email/Email generated on" & "-"

There is no Wait Method associated with Application in VisualBasic Word

时光总嘲笑我的痴心妄想 提交于 2019-12-02 13:59:30
问题 I have VBA code to run a particular code and I am trying to pause the next execution by giving it a wait time of 3 seconds using the following line: Application.Wait (Now + TimeValue("00:00:03")) But I get the following error: Error: Method or data variable not found 回答1: It is best to use External Library references (Early Binding) while developing your code. Early Binding has the advantages of both intellisense and Help documentation. A major disadvantage of Early Binding is that it