word-vba

Referring Excel objects which embedded in a MS-Word Document?

青春壹個敷衍的年華 提交于 2019-12-19 12:22:58
问题 I have many Excel objects are there embedded in a MS-Word Document. I want to calculating the grand total: with summing the totals are there in the each specified excel object and return that grand total in the MS-Word document. Macro holder is MS-Word Document's VBA module. Means: I need to access to an specified embedded Excel object , form the MS-Word module , then perform it active , then assign to an object-variable by -For example:- ExcelApplication = GetObject(, "Excel.Application")

ms word 2010 macro How to select all shapes on a specific page

雨燕双飞 提交于 2019-12-19 11:52:50
问题 The command ActiveDocument.Pages(1).Shapes.Range.Select doesnot seem to work in word 2010. (It used to work in word 2003). I need to select all the shapes on a specified page (say page 1), then delete the first shape and last shape on each page of a 300 page word document. Any help on how to do this will be of great help. Regards Firaq pasto 回答1: UPDATE1 - Removed (only works on inline shapes) UPDATE2 - Removed (only works on inline shapes) UPDATE3 - Removed (Delete using the Shape's Name not

copy-paste tables from word to excel

冷暖自知 提交于 2019-12-19 09:17:12
问题 I have a word document which is updated periodically. I can go into that Word document, select the contents of an entire table and copy, then go into an Excel spreadsheet and paste it. It's screwed up; however, I fix it as follows: sht.Cells.UnMerge sht.Cells.ColumnWidth = 14 sht.Cells.RowHeight = 14 sht.Cells.Font.Size = 10 This manual copy-paste works regardless of whether the table is has merged fields. Then I can start to manipulate it manually: parsing, checking, computations, etc. I can

Identify and populate a listbox

喜夏-厌秋 提交于 2019-12-19 03:58:44
问题 It's a riddle for me: what is the syntax to populate a listbox? But first: how do you identify a listbox? In many forums I read: ListBox1.Additem ... But how do they know it's 'ListBox1'? 回答1: That's the default name for a ListBox control when you add it to your form. VB and VBA automatically name new or unnamed controls with the name of the type of control, suffixed with an integer identifier. It's completely irrelevant what your control is called. The point of the sample code is to

Call a VB macro from java code

时光毁灭记忆、已成空白 提交于 2019-12-18 17:31:08
问题 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? 回答1: You can run vbscript using the "cscript.exe" that ships with windows. Depending upon your scenario, you can launch this from Java in a variety of ways: use Runtime.exec to launch the program. You can do this directly as part of your program. use Ant, which has an exec task, or maven which has an exec plugin. This is most useful when invoking

Building Word fields

拜拜、爱过 提交于 2019-12-18 17:29:48
问题 Apart from just inserting and parsing text into a blank Word field, is there any way to programmatically build user-defined fields and field codes into my own templates with VBA? Furthermore, is there a way to make these fields show up in the list of available fields? 回答1: I recently developed a solution that used Word's MACROBUTTON and ADDIN field types. I found MACROBUTTON useful because the third whitespace-delimited entry inside the field (programmatically field.code.text) is displayed

Find all instances of yellow text and change font color to red

╄→гoц情女王★ 提交于 2019-12-18 16:57:13
问题 I need a vba macro that searches for all text that has font color as yellow within a MS Word 2007 document and changes it to red. The yellow color won't show in the printouts. Manually selecting and changing will take me hours. 回答1: Following on from stakx’s Word 97 solution, here’s what works in Word 2010: Open the Find and Replace dialogue (e.g. Ctrl-H) Click in the "Find what" box. Format drop-down, Font, choose the Font color to be found, OK. Click in the "Replace with" box. Format drop

How to programmatically edit all hyperlinks in a Word document?

拈花ヽ惹草 提交于 2019-12-18 15:01:24
问题 Is there a macro, VBA code or VBScript that I can write to edit the urls of all the hyperlinks in my Word document? Either Word 97-2003 or docx format. 回答1: Dim doc As Document Dim link, i 'Loop through all open documents. For Each doc In Application.Documents 'Loop through all hyperlinks. For i = 1 To doc.Hyperlinks.Count 'If the hyperlink matches. If LCase(doc.Hyperlinks(i).Address) = "http://www.yahoo.com/" Then 'Change the links address. doc.Hyperlinks(i).Address = "http://www.google.com/

How to programmatically edit all hyperlinks in a Word document?

青春壹個敷衍的年華 提交于 2019-12-18 15:00:46
问题 Is there a macro, VBA code or VBScript that I can write to edit the urls of all the hyperlinks in my Word document? Either Word 97-2003 or docx format. 回答1: Dim doc As Document Dim link, i 'Loop through all open documents. For Each doc In Application.Documents 'Loop through all hyperlinks. For i = 1 To doc.Hyperlinks.Count 'If the hyperlink matches. If LCase(doc.Hyperlinks(i).Address) = "http://www.yahoo.com/" Then 'Change the links address. doc.Hyperlinks(i).Address = "http://www.google.com/

How can I reliably get the number of pages in a Word document?

。_饼干妹妹 提交于 2019-12-18 13:06:37
问题 I am making lots of changes to a Word document using automation, and then running a VBA macro which - among other things - checks that the document is no more than a certain number of pages. I'm using ActiveDocument.Information(wdNumberOfPagesInDocument) to get the number of pages, but this method is returning an incorrect result. I think this is because Word has not yet updated the pagination of the document to reflect the changes that I've made. ActiveDocument.ComputeStatistics