word-vba

Specifying location of new inlineshape in Word VBA?

I'm working on a document "wizard" for the company that I work for. It's a .dot file with a header consisting of some text and some form fields, and a lot of VBA code. The body of the document is pulled in as an OLE object from a separate .doc file. Currently, this is being done as a Shape, rather than an InlineShape. I did this because...

How to repaint a Word 2003 menubar

I have a Word 2003 .dot template that changes its menu based on the condition of the active document. The DocumentChange, DocumentOpen and NewDocument events of Word.Application trigger setting the .Visible and .Enabled properties of CommandBarButton controls. On switching active documents, controls exposed by changing the Visible prop...

Use reference to dynamically created control in Word VBA

I am writing a form in Word 2003 to collect multiple responses to a single question. I have a macro on a button press which duplicates the various input fields (drop-down boxes, radio buttons etc.) ready for a new response. However, I need to change the text of the radio buttons, and set the OnChange event on a combobox, and I can't fin...

Link Fields, VBA, and Paste Special in Word 2003

We have a bunch of Word 2003 documents that have images "linked" in from Visio 2003 files, all on Windows XP systems. There are two problems with that: Sometimes the links become randomly corrupted (Word stores the link paths as absolute but somehow the link mostly gets preserved when the files are copied to a different computer). We ...

Word 2007 VBA cannot control Pictures?

Try recording a macro in Word 2007, notice you can't do a thing to pictures. (Or is this a local issue with my machine?) And I can't even find the Picture / Image object within the Word Object Ref. What gives? ...

Is there any more documentation on WordBasic's FilePrintSetup?

I found the WordBasic.FilePrintSetup function when I was searching for a way to change Word's printer without changing Windows' default printer. Unfortunately I could not find any real documentation on FilePrintSetup, even the parameters I found with Google aren't officially documented. (Printer and DoNotSetAsSysDefault) So do you kno...

Programatically insert ActiveX Control into Word Document using VBA?

is it possible? I couldn't find any code that does that. ...

Error when VBA (MSWORD) code is being run for the second/successive times in VB6

...

Opening/Activating Word Documents in a VBA macro

I'm hoping a VB/VBA expert can help me out. Consider the following: The user opens a document in Word 2003, and within the Normal.dot AutoOpen macro, we look at current document, and if it has been opened by clicking on a link on a webpage, and meets certain other application specific criteria, close the streamed 'copy' and open the...

Implement auto-increment with Word macro

I'm writing a Word/VBA macro for a document template. Every time a user saves/creates a new document from the template, the document needs an ID embedded in the text. How can I (as simple as possible) implement auto-increment for this ID? The ID is numeric. The system has to have some kind of mechanism to avoid different documents getti...

How do I delete a command button using Word VBA?

I have a Word document that contains a command button named "update". How can I delete this button using VBA? thanks, Paul ...

How can VBA application use the correct built in styles across English and French versions of Windows/Word.

I developed a Word 2003 report generation application that extracts data from a database. Most of the organization uses English versions of Windows and Office. But, many users in our French office use their local versions. If I use any of Word's built-in Heading styles Heading (1-9), the French version expects Titre (1-9). In my curr...

Excel VBA to Open Multiple Word files in a loop

Hello, I apologize in advance for the newbie question -- most of my VBA experience is in Excel, or Word to Excel. In this case, I am going from Excel to Word. I am trying to capture some data off of some Word forms and store it in an Excel file. Right now, my code works for the first document in the folder, but after that, it hoses up...

Word VBA Can't Exit Design Mode Error (Word 2003)

I have a Word form that has a bunch of command buttons, form fields, and combo boxes. There is a lot of code associated with the form both in the "ThisDocument" object and another module I added. If I open the form by double-clicking the document from Windows, it opens and works fine when I enable macros. However, if I open Word first...

Problem with GetCrossReferenceItems in msword and VBA

Hi I want to make a special list of figures with use of VBA and here I am using the function myFigures = ActiveDocument.GetCrossReferenceItems(Referencetype:="Figure") In my word document there are 20 figures, but myFigures only contains the first 10 figures (see my code below.). I search the internet and found that others had the ...

When using range.find to find bold text it won't find if the entire selection is bold!

I'm trying to extract bold text using the range.find method and all is peachy except if the entire range is actually bold (not likely to happen much, it's more of an edge condition). With rngFindRange.Find .ClearFormatting .Font.Bold = True Do .Execute If Not .Found Then Exit Do End If 'do something with found...

VBA How to get path to The Current Users Application data folder?

In general, Using VBA, how do I determine where the Current users Application Data folder is? The FileSystemObjects special folders only knows about 3 folders WindowsFolder SystemFolder TemporaryFolder Specifically, I need a Word Macro to copy a file to the a folder under the Application Data folder. e.g. In VB.Net I can use My....

Word macro, storing the current selection (VBA)

Hi, I have a Word document that contains about 4000 form fields which I have to export afterwards to a database. The matter is that none of the 4000 fields have an information in the "Bookmark" field, thus I cannot get the information stored in them. I'm trying to create a macro to help the process of writing the bookmark (FormField.Nam...

Word vba - if cursor is in cell / bookmark - run code

Hi, I have a template document which contains several sections and a few tables. The thing is, I'm trying to insert a drop-down list inside on of the cells in the table. And for a drop-down list to work, the document needs to be protected. But if I protect the entire section the table is in, the entire table is protected. So, I was w...

Read Index (Table of Content) of word document

I am interested to get the topic headings (say all lines with Heading 1 and Heading 2) from a word document. Using VBA you can parse thru every line in that document and verify the style; however this seems to be a tedious job. I believe that there should be some easy way of doing it. Any pointers ...