word-vba

How To Deploy Word 2010 Macros To Others?

怎甘沉沦 提交于 2019-11-29 04:35:00
I have a macro that I developed in Word 2010. How do I send this to others to use? Save the document as .dotm (macro enabled template). Save it to %Appdata%/Microsoft/word/startup Close word. Now, it will be accessible to all other word documents. If not by default, then go to templates and tick the file saved above to deploy, create a simple script that copies the file to the appropriate folder. You can probably deploy via email From the sublime to the ridiculous, here are four different options: Create an add-in. Distribute and tell others to install it. Instructions Create a COM add-in.

Modify embedded Excel workbook in Word document via VBA

给你一囗甜甜゛ 提交于 2019-11-29 04:18:56
I have a Word document with two embedded Excel files (added using Insert -> Object -> Create From File) which I wish to modify using Word VBA. I have got to the point where I am able to open the embedded files for editing (see code below), but am unable to get a handle on the Excel workbook using which I can make the modifications and save the embedded file. Does anyone have a solution for this? Thanks in advance. Sub TestMacro() Dim lNumShapes As Long Dim lShapeCnt As Long Dim xlApp As Object Dim wrdActDoc As Document Set wrdActDoc = ActiveDocument For lShapeCnt = 1 To 1 'wrdActDoc

Add an Image to Word Document and Scale it using VBA

南楼画角 提交于 2019-11-29 02:16:50
how do i programatically add an image using VBA to a word document. I've tried adding a bookmark to the word document and tried adding the image, but it always adds to the top of the form rather than the bookmark area. Should i persevere with the bookmark or is there another way to add the image? See my code below: Dim wrdApp As Word.Application Dim wrdDoc As Word.Document Set wrdApp = CreateObject("Word.Application") Dim objWdRange As Word.Range Dim GraphImage As String Dim shortString As String shortString = Range("short").Value GraphImage = "http://xxx.xxxxx.com/xxx/xxx.png?instrument=Image

Return multiple values from a function, sub or type?

纵然是瞬间 提交于 2019-11-28 16:18:15
问题 So I was wondering, how can I return multiple values from a function, sub or type in VBA? I've got this main sub which is supposed to collect data from several functions, but a function can only return one value it seems. So how can I return multiple ones to a sub? 回答1: You might want want to rethink the structure of you application, if you really, really want one method to return multiple values. Either break things apart, so distinct methods return distinct values, or figure out a logical

word vba: webbrowser not navigating for ReadyState to check

走远了吗. 提交于 2019-11-28 14:41:00
I am trying to extract links from webpages, but it seems webbrowser does not navigate, so I get infinite loop at webbrowser1.readstate <> readystate_complete... HOWEVER, if make a breakpoint at webbrowser1.readstate <> readystate_complete, the webbrowser navigates successfully in the userform, and code works.... Any ideas? Thanks Do Until n = num WebBrowser1.Navigate URL Do While WebBrowser1.readyState <> READYSTATE_COMPLETE Loop If WebBrowser1.readyState = READYSTATE_COMPLETE Then 'code end if n = n +1 loop noseratio The while loop you use in your question and in your answer is a busy waiting

Capturing keydown event of MS Word

隐身守侯 提交于 2019-11-28 14:31:28
I want to capture the backspace event, just do the backspace's action, then add other action, but I am not sure the backspace's original action:Selection. Delete , -1 ? Sub AddKeyBinding() With Application ' \\ Do customization in THIS document .CustomizationContext = ThisDocument ' \\ Add keybinding to this document Shorcut: Backspace .KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyBackspace), _ KeyCategory:=wdKeyCategoryCommand, Command:="TestKeybinding" End With End Sub ' \\ Test sub for keybinding Sub TestKeybinding() Selection.Delete , -1 ' I am not sure how to impl the original command If

Cannot instanciate a NotesUIWorkspace from VBA (Word)

扶醉桌前 提交于 2019-11-28 12:59:45
问题 The source situation: I have an Notes Application which uses MS Office 2000 under Windows XP. The new situation has to be MS Office 2010 under Windows 7. IBM Notes is 8.5.3FP3. The old one uses a VBA template to communicate with Notes which works properly. At one time a Notes.NotesUiWorkSpace object is created to open a document, navigate to a richtext item, select all the content (formatted) and copy to the clipboard. Then the clipboard content ist pasted into the Word document via VBA. That

MS Word Macro to increment all numbers in word document

Deadly 提交于 2019-11-28 11:57:39
问题 I am trying to make a MS-word Macro to increment all numbers in the word document which are within brackets, eg original numbers [1] [2] [3] [4] , after incrementing all numbers by 10, above numbers will be changed to [11] [12] [13] [14] I'm stuck in the code below and not familiar with VBA before. Can anyone suggest, what to add in code below to perform above macro?? Sub IncrementNumbers() ' ' IncrementNumbers Macro ' ' Application.ScreenUpdating = False Dim RngStory As Range, StrStart As

How-to: Run existing Word VBA Macros from C# Ribbon Addin

谁说我不能喝 提交于 2019-11-28 11:39:35
Background: I have an extensive set of specialized VBA macros used in Word for document formatting purposes. In Word 2003, these macros were activated from a customized toolbar. I have recently transitioned to Word 2007 and would like to be able to run these existing VBA macros from a new Word Ribbon created with VS 2010. I have created a Ribbon; however, I cannot figure out how to call the existing macros from the new Ribbon buttons. Question: How do I call the existing VBA macros, which are stored in a .dotm template, from the C# Word Add-in? Any help would be greatly appreciated. Heinzi The

Searching for Text in Header Section of A Word Document

流过昼夜 提交于 2019-11-28 10:11:10
问题 I am trying to confirm if a document contains some text, the only problem is this text is in the Header. This is the code I am using which constantly returns false even though the text exists: Set CurrentDoc = Documents.Open("a.doc") With CurrentDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Range.Find .Text = "This is the text to find" .Forward = True .Execute If (.Found = True) Then Debug.Print "Match" End With The following also doesn't seem to work (I assume .Content doesn't include