word-vba

Progressbar inside userform

空扰寡人 提交于 2019-12-06 05:40:12
I am trying make a progress bar inside a userform, instead of having a seperate progressbar, because this seems to be unreliable in the respect if it will be on top or in the background. So the progressbar is working fine, however it makes the whole userform repaint for every update the progressbar does. Is it possible to just refresh the progressbar instead of the whole userform? My current code do look like this: Public Sub progress(pctCompl As Single) Me.Text.caption = Format(pctCompl, "##") & "% Completed" Me.Bar.width = Round(pctCompl * 10, 5) If Me.Bar.width Mod 20 = 0# Then Me.Repaint

Word VBA: Moving textstring from the end of a paragraph to the beginning of the paragraph

杀马特。学长 韩版系。学妹 提交于 2019-12-06 05:09:38
I'm new to VBA. I have several long documents where a citation or a document number appears at the end of a paragraph. Luckily, these citations and document are enclosed in parentheses, which should make it easy to isolate. I need to move the content of those parentheses (including the parentheses themselves) to the front of each paragraph and then add two spaces after the closing parenthesis. For example: This is my text in Paragraph 1. ( http://nytimes.com ) This is my text in Paragraph 2. (1.b.3B) Should look like: ( http://nytimes.com ) This is my text in Paragraph 1. (1.b.3B) This is my

Select ListBox item on rightclick in Word VBA

不羁的心 提交于 2019-12-06 04:46:54
I'm developping a project in Word 2003 with VBA. I have a multiselect ListBox with some entries (dates). On rightclick I'd like to have an InputBox popping up where the user can change the selected date. This works well, as long a specific item is already focused (not only selected, but focused). But, if you rightclick on an item without focus, the box shows up and changes the date of the focused entry, not always the one you rightclicked. I found this answer ( http://www.vbarchiv.net/tipps/tipp_920-rechtsklick-in-der-standard-listbox-erkennen.html ) but it's not possible in VBA. Has anyone a

Error 462 in VBA : remote server machine not found

本秂侑毒 提交于 2019-12-06 02:40:59
following code is to read a word file in vba. But its showing an error Error 462 in VBA : remote server machine not found. Sub abc() Dim fileReader As String Dim wrdApp As Word.Application Dim wrdDoc As Word.Document Dim singleLine As Paragraph Set wrdApp = CreateObject("Word.Application") Set wrdDoc = wrdApp.Documents.Open("C:\Documents and Settings\Administrator\My Documents\Downloads\fwfiles\webs.doc") With wrdDoc Dim p As Paragraph For Each p In wrdDoc.Paragraphs fileReader = p.Range.Text Next p End With End Sub Thanks in advance Does it break when you launch it twice ? Cause Visual Basic

How do I retrieve the name of a shape in MS Word?

江枫思渺然 提交于 2019-12-06 02:36:49
问题 In Excel we have the "Name Box" in the upper-left side, but I could not find a way to retrieve the name of a shape in Word. How do I do that? 回答1: There are two types of shapes in MS Word- InlineShapes and Shapes . It's quite easy to check name of shape object with some VBA code: select shape press Alt+F11 to open VBA Editor in Immediate window execute this code: ? Selection.ShapeRange.Name as a result you get name of the shape. InlineShape doesn't have name property therefore you can't check

Regex Word Macro that finds two words within a range of each other and then italicizes those words?

隐身守侯 提交于 2019-12-06 01:31:28
问题 So, I'm just beginning to understand Regular Expressions and I've found the learning curve fairly steep. However, stackoverflow has been immensely helpful in the process of my experimenting. There is a particular word macro that I would like to write but I have not figured out a way to do it. I would like to be able to find two words within 10 or so words of each other in a document and then italicize those words, if the words are more than 10 words apart or are in a different order I would

How to insert text into TextBox in Word Macro

匆匆过客 提交于 2019-12-06 00:27:45
I created a text bo in the Word and I would like to insert text into it: Sub k() Dim Box As Shape Set Box = ActiveDocument.Shapes.AddTextbox( _ Orientation:=msoTextOrientationHorizontal, _ Left:=50, Top:=50, Width:=100, Height:=100) //HOW TO INSERT HERE TEXT INTO TEXT BOX End Sub Here is the solution: Sub k() Dim Box As Shape Set Box = ActiveDocument.Shapes.AddTextbox( _ Orientation:=msoTextOrientationHorizontal, _ Left:=50, Top:=50, Width:=100, Height:=100) 'The solution for you: Box.TextFrame.TextRange.Text = "My text comes this way" End Sub 来源: https://stackoverflow.com/questions/17126517

How to get list of all bookmark-elements from a Word document to an array in order by location: VBA / Word

本秂侑毒 提交于 2019-12-05 21:52:21
I want to fetch all the bookmarks in my Word document, and then push them to an array. The bookmarks must be sorted by their location in document not by name. ex. here's a list of bookmarks in a document, [bm_s] (header) [bm_h] (title) [bm_a] (footer) I want the bookmarks to keep their order so that the array will look like as following, array {bm_s, bm_h, bm_a, } ex. how it should not look like below, array {bm_a, bm_h, bm_s, } I got the fetching of all the bookmarks from document working. I get all the bookmarks in random order when fetching and pushing to the array. Oki, so i figured it out

What are the benefits of MS Word content controls?

孤街浪徒 提交于 2019-12-05 21:12:59
Office 2007 brings a new goodie called as 'content controls'. I need to evaluate this to see if this serves as a solution for a problem under research. Due to paucity of time and my general disdain for Office-interop-pains, can someone summarize the benefits? Is it possible to define custom content controls? where do all the word programmers (if there are any) hang out :) ? RTFMsdn links also welcome. So far I see (from some screencasts) that its now possible to define - template word docs whose content can be stubbed in from a data-behind-XML. You could create this XML as you wish.. e.g.

Copy shape in Word 2010 without .Select?

孤街醉人 提交于 2019-12-05 20:34:04
Is it possible to copy a shape in Word 2010 without resorting to .Select ? According to Dev Center the Anchor property returns the shape's anchoring range. Could that be a way forward? However, the code below returns an error. Sub createShape() Set myShape = ActiveDocument.Shapes.AddShape(msoShapeRectangle, 1, 1, 1, 1) myShape.Anchor.Copy End Sub While it does not seem to be possible to copy a shape without selecting it, it is possible to duplicate a shape without selecting it (which was my reason for wanting to copy it in the first place). The code below gives me what I was looking for: Sub