word-vba

VBA Macro to search a text string and replace with hyperlink works only with English text, but not Arabic

妖精的绣舞 提交于 2019-12-02 13:17:03
I have Arabic texts in Microsoft Word that I need to introduce hpyerlinks to some of its words. The reply to this question here works for me, but only for English words. When I replace the word "google" with any Arabic string (Whether one word or multiple words), the macro does not work. I can display the Arabic characters correctly in VBA, using the answer to this question here , so there are no problems displaying the text in the macro. Can you please help me understanding what code modifications I need to have, in order to get the macro to recognize the arabic text? Needless to say, the

Quit Word.Application which opened in the child subrotine

北战南征 提交于 2019-12-02 13:03:12
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 | Function Pro1 As Word.Document 'Declaration Dim objWord As Word.Application ' Here we declare a Word

Loop comparison macro

橙三吉。 提交于 2019-12-02 12:39:59
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:=Documents("spool1.txt"), Destination:= _ wdCompareDestinationNew, Granularity:=wdGranularityWordLevel, _

Sharing VBA modules across MS Office Applications

会有一股神秘感。 提交于 2019-12-02 12:24:39
问题 I have a substantial bank of VBA modules written in an Excel 2010 add-in. Some of these are specific to Excel, but many are more general. For example one takes a part number and re-formats it; another contains a Case Select function to find a file in a network drive. I want to use the common functions in Word and Outlook. I could copy and paste from the Excel to Word add-ins, but this makes it difficult to keep my code up to date - when I make an edit in one application, I must remember to

Extract data from content controls in Word to Excel

北城以北 提交于 2019-12-02 12:09:26
问题 I have a Word document that is "form-fillable", i.e. it has content control objects in it such as rich text and date picker content controls. I am looking to extract the data from specific fields into Excel. For example, every form has the project title, start date, and manager. I would like 1 row for that form with those three pieces of data. Eventually this will need to be done for a few hundred of these forms every few months, but for now I'd like to just start with one. I envision having

VBA macro: replace text in word file in all sub folders

北城余情 提交于 2019-12-02 09:34:49
问题 I am putting together a VBA macro that: 1.reads a folder 2.creates a collection of all its subfolders 3.loops through all the subfolders and find any word document ending in .doc 4.in each .doc file: replace a bit of text and save then close the documents. This macro doesn't work correctly: it doesn't replace the text in any word documents in the subfolders. It doesn't actual open any word document, I am unsure wether it should open each word doc one after another or if it runs in the

Is there a place to store VBA code that's accessible to all Microsoft Office products..?

情到浓时终转凉″ 提交于 2019-12-02 08:08:59
问题 Is there a way of storing VBA source code that's common and accessible to all Microsoft Office products..? I have a variety of functions which I use in both Access and Excel, and sometimes even Word. I modify and add to the the functions and modules frequently. The copying, pasting, and maintaining of code between projects can get tedious, and I inevitably overlook something. I know I could do something like write a class/ocx/addin in VB6 or DotNet, compile it, and reference it in my VBA

VBA to copy text from excel to on specific location in wordfile

元气小坏坏 提交于 2019-12-02 07:32:44
Problem: Pasting copied data from excel to specific location in a word file. Currently I have code which can paste the value, but it does so to "paragraph1" myDoc.Paragraphs(1).Range.Paste How do I specify the exact location (by line) in which to paste the data? Let me know if more info is required. Thanks! Mohd Akhtar You could also use some bookmarks: You can choose where you put your bookmark and then write on it like this ThisDocument.Bookmarks("NAME_OF_THE_BOOKMARK").Range.Text = THE_EXCEL_DATA To place a bookmark you have to click on the selected area and then go on Insert->Bookmarks and

Iterating XML nodes using VBA

為{幸葍}努か 提交于 2019-12-02 06:10:59
问题 Note:- It just might be a iterating XML nodes using VBA question. Please look at the bottom of this question. It would be good If we can iterate without using MSXML2.DOMDocument I see the this question which answers part of my question on how to retrieve the CustomXMLPart. However, I am not able to iterate through the Xml. That way, this might not be specific to CustomXmlPart, It just might be a iterating XML using VBA question. Following is the XML I have in my CustomXMLPart. <Items> <Item1

Delete doc when macro finishes

非 Y 不嫁゛ 提交于 2019-12-02 06:09:34
问题 I have a Word 2007 docm file that I send to users as an email attachment to let them update files. The macros download files from a server and install them correctly - as opposed to sending the files as email attachments and trusting users to get it right. I'd use a VBScript file instead, but I'm not allowed to send that in an email. I would like to delete this document from the user's computer when the macro finishes. But the doc is still open and the macro still running when it hits any