Bug with cell merging in tables using Applescript

Version: 2008
Operating System: Mac OS X 10.6 (Snow Leopard)
Processor: Intel

Once you have merged cells in a table in Word 2008 using Applescript, any further reference to the table's cells in the script produce an error. <br><br>As an example, open Word 2008 and run this script: <br>
tell application &quot;Microsoft Word&quot; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;make new table at active document with properties {number of rows:4, number of columns:4} <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set mytable to table 1 of active document <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merge cell (cell 1 of row 1 of mytable) with (cell 1 of row 2 of mytable) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merge cell (cell 1 of row 3 of mytable) with (cell 1 of row 4 of mytable)&#09; <br>
end tell <br><br>The script inserts a 4x4 table, merges the left hand cells of rows 1 and 2 as it should, then fails with error &quot;Microsoft Word got an error: The object you are trying to access does not exist&quot; number -1728 from cell 1 of row 3 of table 1 of active document. <br><br>Any reference to a cell made in an Applescript after merging cells will produce the error. For example substituting "select (cell 3 of row 3 of mytable)" for the last line of the script produces the same error on running the script. <br><br>Is this a bug or am I missing something?
0
backroomboys
3/24/2010 3:29:12 PM
mac.office.word 1676 articles. 1 followers. Follow

3 Replies
1926 Views

Similar Articles

[PageSpeed] 42

AFAICS you cannot reference row objects within a table once you have 
merged cells in a column and you cannot reference column objects once 
you have merge two cells in a row.

You can however do this:

tell application "Microsoft Word"
	make new table at active document with properties {number of rows:4, 
number of columns:4}
	set mytextobj to text object of table 1 of active document
	merge cell (cell 1 of mytextobj) with (cell 5 of mytextobj)
	merge cell (cell 9 of mytextobj) with (cell 13 of mytextobj)
end tell

but you will obviously need to keep track of how the cell numbers change 
as you go along!

(FWIW I do not know whether you would get this problem with rows etc. in 
Word 2004 + VBA or the Windows version of Word)

Peter Jamieson

http://tips.pjmsn.me.uk

On 24/03/2010 15:29, backroomboys@officeformac.com wrote:
> tell application "Microsoft Word"
>          make new table at active document with properties {number of
> rows:4, number of columns:4}
>          set mytable to table 1 of active document
>          merge cell (cell 1 of row 1 of mytable) with (cell 1 of row 2
> of mytable)
>          merge cell (cell 1 of row 3 of mytable) with (cell 1 of row 4
> of mytable)
> end tell
0
Peter
3/24/2010 7:36:12 PM
I'm going to stick my neck way out on the chopping block here and suggest
that you are destroying the object you are trying to reference.

When you "set mytable to table 1..." you have set a reference to an area in
memory.

Then when you do the merge, the shape of the table changes in memory and the
object is destroyed.

I am guessing (guessing!!) that if you re-write the code without the
"set..." statement, it will work (very slowly!) because then you will have
to resolve cell 1 of row 1 of mytable table 1 of active document on each
iteration.

I seem to remember that Word has an issue with cells in rows in a table.
You may be better to address the cell directly (cell 11 of table 1).

Hope this helps

On 25/03/10 2:29 AM, in article 59bb5d7d.-1@webcrossing.JaKIaxP2ac0,
"backroomboys@officeformac.com" <backroomboys@officeformac.com> wrote:

> Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel
> Once you have merged cells in a table in Word 2008 using Applescript, any
> further reference to the table's cells in the script produce an error.
> 
> As an example, open Word 2008 and run this script:
> tell application "Microsoft Word"
>         make new table at active document with properties {number of rows:4,
> number of columns:4}
>         set mytable to table 1 of active document
>         merge cell (cell 1 of row 1 of mytable) with (cell 1 of row 2 of
> mytable) 
>         merge cell (cell 1 of row 3 of mytable) with (cell 1 of row 4 of
> mytable)  
> end tell 
> 
> The script inserts a 4x4 table, merges the left hand cells of rows 1 and 2 as
> it should, then fails with error "Microsoft Word got an error: The object you
> are trying to access does not exist" number -1728 from cell 1 of row 3 of
> table 1 of active document.
> 
> Any reference to a cell made in an Applescript after merging cells will
> produce the error. For example substituting "select (cell 3 of row 3 of
> mytable)" for the last line of the script produces the same error on running
> the script. 
> 
> Is this a bug or am I missing something?

 --

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410 | mailto:john@mcghie.name


0
John
3/24/2010 11:32:53 PM
I tried Peter's script and the second merge was't quite right - it merged cells in rows 3 and 4 of column 2, rather than column 1. From what you both say, it looked like the first merge altered the numbering of cells below the merge, thereby causing the second merge to go wrong. <br><br>I reversed the order of the merges in the script, so that the first merge was at the bottom of the table and the second was at the top and achieved merging of the cells in the left-hand column as I wanted. <br><br>Thanks for solving this one so quickly! I'll use cell numbering and the bottom to top order of merging in future.
0
backroomboys
3/25/2010 10:01:51 AM
Reply:

Similar Artilces:

namespaces and protected static members VC .NET bug?
I found bug when use namespaces in mfc application. When I wrote DECLARE_MESSAGE_MAP/BEGIN_MESSAGE_MAP in base (CDialog-derived) class A and in class B : public A (A and B in different namespaces). I narrowed this problem to simple peace of code: class A { protected: static int f; static int *p; public: A() {} ~A() {} }; int A::f = 1; int *A::p = NULL; namespace some { class A : public ::A { static int f; static int *p; public: A() {} ~A() {} }; int A::f = 2; int *A::p = &::A::f; // this line produces error } This code does not work, VC compiller said: error C2248...

unable to access my hotmail account using Outlook 2007
I am unable to access my email using Outlook 2007; I keep recieving the message: Folder:Inbox Synchronizing headers. 'reported error (0x80040604) : 'A folder by this name already exists.' I am using Windows Vista Ultimate, and am up to date with available updates. I am unaware of any changes I have made to my system that could have resulted in this and have no idea what to do in attempts to resolve this. Any help would be greatly appreciated. -- Go to your Hotmail mailbox online and empty the Deleted Items folder. Then try again in Outlook. If it still doesn't work...

cell value under VBA
OK, I seem to be mis-coding this. Can anyone tell me what is wrong with this VBA code?.....or a better way to do it? ******* This line is supposed to return a value in a specific cell based on row/column position. The correct values seem to be getting fed into there, but it throws a #VALUE error? Is there a better way to retrieve a specific cell value somewhere on a worksheet? ******* n_Total = Workbooks(s_Book).Worksheets(s_Cases_Sheet).Cells(n_Row, n_Column) #### Sample values for above s_Book = "Inventory_Entry_June_2006.xls" s_Cases_Sheet = "Cases" n_Row = 4 n_Co...

Mirroring cells
I'm trying to duplicate cells exactly from one sheet to the next. I'm using IF commands to get the data entered in a cell in one sheet to show up in the next, but is there anyway to also mirror the format, i.e. bolded text, highlights, etc.? Thanks in advance! -- careyc ------------------------------------------------------------------------ careyc's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=26064 View this thread: http://www.excelforum.com/showthread.php?threadid=476778 Use Copy / Paste. It will copy both the cell's contents and its forma...

BUG? Outlook 2003 Not Responding
Hi all, I'm currently running Outlook 2003 (11.5608.5606) along with Active Sync 3.7 (Build 3083). I have the *Hide When Minimized* option set Outlook (thanks MS!) Since my upgrade, I've noticed the following behaviors: When my pocket-pc is disconnected/off: If I *minimize* Outlook, it hides itself in the system tray, and can (almost) always be restored. If I *close* Outlook closes, and can be restarted. When my pocket-pc is connected/on: If I *minimize* Outlook, it hides itself in the system tray, and can (almost) always be restored. However if I *close* Outlook Outlook minimizes ...

Can I parameter query multiple fields in the same table?
I am setting up a database for our search company that is filled with information on our clients. I need to be able to track the organizations to which our clients are applying. This could be multiple organizations at one time. Then, I need to be able to list which clients have applied to a certain company. I have set up a dropdown list of the companies to make entering them easier for each client. However, the only way I know to do it now is to set up about 10 separate yet identical dropdown fields in each client's record. then, as they apply with different companies, I simply add t...

How to copy an array without changing relative cell refferences?
Hello specialists! How to copy an array to an array of the same size without changing relative cell references in the formulas? Best regards, Dima One way is to change the formulas so that Excel will not recognize them as formulas, do the copy and paste, then change them back. Do this: Select the range (the array) that you want to copy. Click on Edit - Replace. In the "Find what:" box, type "=" without the quotes. In the "Replace with:" box type "Dmitry" without the quotes. Click OK. Copy and paste. Now select the new range and reverse the process. D...

To use JUNK FILTER or RULES
I have OL 2007 in a POP3 configuration. I have thousands of "junk" email and I have created a list of "spammers" that total about 400 email addresses. I have imported these into the Junk Blocked senders list. This will be great for future emails. The question is, is there a way that I can force the processing of the junk blocked senders on email already in my inbox? Or...Should I create a RULE with these addresses? Is there a way to add hundreds of email addresses to a rule? Thanks Good news and bad news: First the bad news: There isn't a good way to force pro...

Transactions By Category Report Bug (Money 2005)
All, I'm experiencing a problem that I can't seem to work around and I hope somebody can help me out. I ran the transaction by category report and selected category A. I then went to the category setup screen and moved category A into B. I then went back to the transactions by category report and this time it won't open. Instead, it acts like it's going to open, but then immediately reverts back to the report menu screen. I'm pretty sure it's doing that because the last selected category the report ran was for category A and that category doesn't exist anymore...

Email via Mail Merge
The 'Email via Mail Merge' option in the Create Quick Campaign Wizard is not there. I am using the outlook client, the 'Letter via Mail Merge' is there, the bulk email service is running (although I don't think it uses this), the option 'Enable Direct E-mail via Mail Merge' is selected in System settings. Any ideas how I make it appear in the list? "Helen" <Helen@discussions.microsoft.com> wrote in message news:15935F4E-8AF0-446C-812F-76A9E84E0973@microsoft.com... > The 'Email via Mail Merge' option in the Create Quick Campaign Wiza...

How do I NOT leave blanks where a field is empty in Catalog merge
If it is not already open, open your catalog merge template. On the Tools menu, point to Mail and Catalog Merge, and then click Mail and Catalog Merge Wizard. In the Mail and Catalog Merge task pane, click Next: Select data source. Under Select data source, click Edit record list. Click the arrow next to the column heading of the item you want to filter by. To exclude blank records from your merge, click (Nonblanks) to display all the records in which the corresponding field contains information. The Catalog Records dialog box displays only the designated records. To display all the re...

can we enable and disable menus when we right click on any cell
can we enable and disable menus when we right click on any cel -- Message posted from http://www.ExcelForum.com You don't really give any details, but you could use an event, like this. where right clicking on A1 will disable the control, and right-clicking on any other cell will enable it. Private Sub Workbook_SheetBeforeRightClick( _ ByVal Sh As Object, _ ByVal Target As Range, _ Cancel As Boolean) With Application.CommandBars("Bar Name") _ .Controls("Menu Name") If Target.Address = "$A$1" Then ..Enabled = False Else ..Enabled = T...

Using name from address book in lieu of actual email address
The following is an extract of code that I use to send emails from an Excel program. How can I modify it to use peoples names as they appear in my address book in lieu of using their actual email address for .To, .CC and .BCC strTo = "ossiemac@ossiemac.com" 'Sample. Not valid email address strCC = "myfriend@friends.com" 'Sample. Not valid email address strBCC = "secretfriend@secrets.com" 'Sample. Not valid email address Set objMail = objOutlook.CreateItem(olMailItem) With objMail .To = strTo .CC = strCC .BCC = s...

Using numbers in a cell
How do you change the default settings to allow all numbers to be show? For example 000635 will show up as just 635. Check your other post, you have 2 answers John "Texraid" wrote in message news:rt54p4hhagod2irv4dsu1ssiafendhurkp@4ax.com... > How do you change the default settings to allow all numbers to be > show? For example 000635 will show up as just 635. ...

How to know width and height of merge cells?
I merge 2 cells, A1+B1. I wanna know width and height of the merge cells. How to know it? Dim cell As Range If ActiveCell.MergeCells Then For Each cell In ActiveCell.MergeArea MsgBox cell.Address & " width = " & cell.ColumnWidth & " height = " & cell.Height Next cell End If -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Bpk. Adi Wira Kusuma" <adi_wira_kusuma@yahoo.com.sg> wrote in message news:Ouofc%23lBHHA.4740@TK2MSFTNGP03.phx.gbl... > I merge 2 cells,...

How do I leave out blank cells in a line graph?
I have a line-graph linked to a table of data. Some cells in the data table are blank (these cells have an apostrophe in), and at the moment the line graph displays these cells as zeros. But I'd like these blank cells to be omitted in the graph, and not displayed as 0. I've tried 'Tools>Options>Chart>' but the 'Plot empty cells as Not plotted is greyed out'. Can anyone help?! Either blank, or with an apostrophe, won't be treated as empty. If the cells aren't totally empty, try replacing the contents by N/A#. Perhaps IF(ISNUMBER(A1),A1,NA()). --...

Item Dynamic table size
Hello,e I've been doing some cleaning in our HQ db on items that are no longer sold in our locations. I've had success in deleting the appropriate items however I noticed that our item dynamic table is quite large, over 2,000,000 rows. Is there an sql script available to update the Item Dynamic table based on the Items in the Item table? Thanks in adavance Joe This is a multi-part message in MIME format. ------=_NextPart_000_0020_01CA9A95.F6339260 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Joe, Bad idea to de...

Create a Table with uniformed sized cells?
I am making a calendar withy calendars inside it. I need to lock the size of the cells in the table and can't seem to figure out how.... You can't lock the cells. You could place the main calendar on the Master Page... Or adjust the cells how you want them, copy the table, paste special as an image. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com http://officebeta.iponet.net/en-us/publisher/FX100649111033.aspx "ATG Maggie" <ATG Maggie@discussions.microsoft.com> wrote in message news:832802C9-0CC9-459A-A9E6...

OL2003 Signature Bug?
I have four pop-mail accounts in a single profile. I'll call the Accounts A, B, C, and D. "A" is the default account. In OL2003, you are able to create a different signature for each account. I have created "New Message" and "Reply-to/Forward Message" signatures for two of the accounts (A and C). When creating a new message, the signature for A appears correctly by default. If I switch the "send from" account to C, the signature for C replaces the signature for A. This is expected. If instead, I switch to accounts B or D, the signature...

Can't format cell color/text color in Office Excel 2003 in files .
Just loaded Office 2003 and now cannot change cell color or text color in Excel sheet created in Office 2000. Cells are not protected or locked and file is not read only. Other alterations such as font changes are possible. Any ideas? Thanks! ...

Money 2006 net worth bug
I have noticed that one of my net worth over time favorite reports refuses to load. If I watch the CPU, it appears that $ is in an infinite loop with the load bouncing back and forth between 50 and 80%. But the really amusing thing is this: during the loop if I select "custom date", change either the start or stop date (move either to a new date, or just touch one - change a date and move it back) and select the APPLY button, the load will converge. If you select the OK button, the load will not converge. I have saved a net worth report that converges and attempted to reload...

help with quote program using muliple prices for one quantity {cross post}
Okay, Forgive me ahead of time, I really don't know much about Excel. I can work with templates and create simple formulas but alot of what I read here comes across as "Excelspeak" to me. Here is what I want to do: I have a price list sheet created. This price list has cells labled by name and then "duration", basically for every item there are four prices, based on duration of a rental or sale. I want to create a quote program that will pull data from the price list based on the quantities entered in the quote program. For example Price list is "System A, des...

How to tell Excel to insert cells and shift down from Access
Hi all, I have Access 2003. I am trying to tell Excel to insert cells and shift cells down from Access, with this line of code: oWksh.Cells.Insert Shift:=xlDown But Access does not like that line. It gave me run-time error 1004. I know if has to do with the part Shift:=xlDown Can you suggestion what I can do? Thank you in advance, Ben "Ben" <Ben@NoSpam.com> wrote in message news:eSZuzcDpKHA.1892@TK2MSFTNGP02.phx.gbl... > Hi all, > > I have Access 2003. I am trying to tell Excel to insert cells and shift > cells down from Access,...

VC 6.0 can't handle use an include directory that has spaces in na
i have an environment variable, BUILPATH which has a value of "C:\app build path\common". in a VC++ 6.0 project I use the BUILPATH variable to point to where my include directory is located. i then have a #import statement in the stdfx.h where i just use the tlb's file name. however when i go to compile the project i get : command line warnings D4024 : unrecognized source file type 'build' command line warnings D4024 : unrecognized source file type 'path\common\include /I C:\app' command line warnings D4024 : unrecognized source file type 'build' c...

Is this a bug or not?
I replied to an email that was archived in Outlook 2007. The 'sent' copy was placed in the archived sent folder instead of the one in my personal folders. Is this normal or a bug? Is there anyway that I configure responses to archived 'mails to be put in the current sent folder? TIA. Cheers, Guy ** Stress - the condition brought about by having to ** resist the temptation to beat the living daylights ** out of someone who richly deserves it. "Dr Teeth" wrote in message news:db8si3lpuejhnpm3luacpu2rkkaef66stt@4ax.com... > I replied to an email that was archiv...