word-vba

Single Source Document in Word with VBA

Is there a way to do a "Single Source Document" in Word via VBA or other techniques. My company creates training and wants to have a "master document" that hosts everything in the training and then from that, create the delivery modalities and materials. For example, a single master course would be able to be queries to output A traine...

Macro for one-to-many splitting of Word documents

I have a Word document which is several hundred pages long. I would like to use a macro to automatically create about a dozen or so sub-documents based on certain rules (mainly, occurrence of certain strings in each Section). Is this possible? What VBA functions should I read-up on? Does anybody know of any code examples which are even...

Script for changing fonts in a Word document

I have a Word 2007 file and I want to change all usage of the Courier New font into a Lucida Console font. I need a script that find all words formatted in that font and change it to the new font. How can I do that? ...

Word Macros Problem: MsgBox function appears to lock all open windows of word

I have some macros that run in Word. We are migrating to Office 2007. Problem: the MsgBox function appears to lock all open windows of word. Any Ideas on how to get around that? (It is a macro that walks a user through a bunch of prompts for information that they enter into user forms and or MsgBoxes.) The error says: The command ...

How to generate Tooltip, Quickinfo or Notification without Mouseover event in Word VBA?

Is there any possibility in MS Word with VBA to show a short notification message to the user as he begins creating his Word document. I would like to display a short message to him, something like a notification (quickinfo, tooltip but control independent), which displays for about 30 seconds and dissapears automatically, so that the us...

How can I loop through every letter in MS Word using VBA?

I have about 100 Word documents which include transliteration of foreign names. The author of these documents used a special font called e2 which has about a dozen special transliteration characters (all of which are available in Microsoft Sans Serif font). I would like to loop through every letter of the document and whenever the .Font...

How can I use an Access query which uses Access-VBA-defined functions in Word VBA?

State of the question: I no longer think it is relevant that I'm referencing Excel or that the query has parameters. I think question boils down to this: How can I use an Access query which uses Access-VBA-defined functions in Word VBA? What I want to do is impossible, how can I make an inlined version of the Acos function work with my...

Word 2003 - How to use a Macro to Change styles?

Is it possible to create a Word 2003 Macro to change the font style of certain segments of a document? For example, say I have a document that has a large portion of text as bold italic and 12 point font. I'd like to replace all text with these characteristics with underlined 14 point font. I've already done some searches on Google,...

Determine whether a Canvas has been inserted into each page in Word

Hi, Currently i have a code which will print OMR Mark on each pages. Basically i insert a Canvas into each page and subsequently an OMR Mark Line Series are inserted into the Canvas. Recently i found an issue that somehow one of the canvas is placed out of a page and it appears at the previous page instead of the current page. Below i...

VBA + Send Mail from Word 2007

I got below code in my Word Document (office 2007) to send a mail with attachement It throws syntax error (file not found) at line .Attachement.Add "C:\abc.txt" Code: Private Sub CommandButton1_Click() Dim outlookapp As Object Dim item As Object Dim subject As String Dim msg As String Set outlookapp = CreateObject("outlook.app...

Searching a document for multiple terms in VBA?

I'm trying to create a macro to be used in Microsoft Word 2007 that will search a document for multiple keywords (string variables) located in an external Excel file (the reason for having it in an external file is that the terms will often be changed and updated). I've figured out how to search a document paragraph by paragraph for a si...

In Word, Programmatically Open New Document Dialog

I am looking for a way to programatically open the "New Document" dialog in Word 2007. It is the same one you get when you select File->New . You can also open it using the FileNew macro or the "New..." menu command. However, I have been unable to find a way to do this programmatically. I have tried: Application.Run MacroName:="Fil...

How can I iterate through table styles only?

I have a procedure that iterates through the styles available to a document: Sub EnumerateStyles() For Each Style in ActiveDocument.Styles `some custom code` Next End Sub I do not need all the styles, and just those that are applicable to tables only. How can I programmatically filter the styles? Thank you ...

How to Jump to a Bookmark in Word-VBA and insert text?

I am trying to create a Word document with a very simple word macro. The macro searches for a bookmark that I have placed in the text and then adds a date, 2 weeks into the future, at that location. But when I create a new document from the template I keep getting bookmark not found. I have been through it loads of times and sometimes t...

Call a VB macro from java code

I have a VB macro created. I want to pass the macro a string and a file location. How would I call this in java code. Is there a library for this? ...

How do you change the subdocument location in a Word 2007 master document programmatically?

We have had the unenviable happen: various master documents refer to sub-documents that are no longer where they used to be due to a directory renaming. Is there a programmatic way of tweaking the HYPERLINK field without losing the master/sub-document relationship? I've got this far ... Sub FixyaLinks() Dim s 'As String Dim i A...

word macro to save a selected range into database.

Is there a way in word to save a selected portion into the database(Ms Access) as range object.So that we can later retrieve it . It is required to generate a report in word ,the section needs to be repeated many times. I have searched net for quite some time but not much material is found. thanks. eg:In a Resume automation application. ...

Compress Images in Office with VBA

I'm looking for a way to programmatically emulate PowerPoint and Word's behavior of compressing pictures to 150 or 96 dpi (ppi) (and removing crops, if there). I need to make a whole ton of presentations and documents smaller for distribution and can't open them up one by one to change DPI by hand for all of them. Is there any way to do ...

Create bookmark into 1st column of MSWord table

Hello All, does anyone have a VBA code to create a bookmark into the first column of an MSWord table? Let's say I have a table looking like this .-----.----------------. . ref . Title . .-----.----------------. . 1 . Title 1 . .-----.----------------. . 2 . Title 2 . .-----.----------------. . foo . Title 3 ...

How to insert hyperlink into access database via sql?

I have a fairly simple MS Access Database that contains some metadata about a bunch of documents and a hyperlink field that links to the document on our network drive. However, when I use a SQL INSERT statement to populate the hyperlink field, the value I give it only becomes the display text, not the actual link. How can I make the va...