Sitemap

Amicuk Programming Answers

Microsoft Word API for Mac OS: Troubleshooting the Find/Replace function

2015-10-11   Views:2

Advertisement

In my previous topic at http://discussions.apple.com/thread.jspa?threadID=2623068&tstart=0 we found out the way to connect to the Ms-Word from Objective-C through ScriptingBridge. The connection works and the given text can be found and replaced usin

In my previous topic at
http://discussions.apple.com/thread.jspa?threadID=2623068&tstart=0
we found out the way to connect to the Ms-Word from Objective-C through ScriptingBridge.
The connection works and the given text can be found and replaced using the method executeFindFindText: Although it generates exception and I am forced to put it in @try block and then continue with everything else in @catch.
There is another, more important problem: the WordFind class does not seem to "give feedback" i.e. I could not find the way to programatically find out whether my find/replace was successfull, nor could I set WordFind object properties prior to running.
The Class WordFind has many properties e.g.
@property (copy) NSString *content; // Returns or sets the text in the find object.
@property (readonly) BOOL found; // True if the search produces a match.
@property BOOL matchWholeWord; // Returns or sets if the find operation locates only entire words and not text that's part of a larger word.
I tried to set the property "matchWholeWord" or read the properties "found" and "content" but in vain.
As I understand, the property "found" should be the key component in my process because it should
return the BOOL value I need.
What am I doing incorrectly? Any suggestions?
Here is the final code:
#import <Cocoa/Cocoa.h>
#import "Word.h"
int main(int argc, char * argv[])
if(NSApplicationLoad())
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
wordApp=[SBApplication applicationWithBundleIdentifier:@"com.microsoft.Word"];
if([wordApp isRunning])
WordDocument *activeWordDoc=[wordApp activeDocument];
WordTextRange *allTextRange=[activeWordDoc textObject];
WordFind *findObj=[allTextRange findObject];
NSString [email protected]"FirstText";
NSString *[email protected]"SecondText";
[findObj setMatchWholeWord:YES];
NSLog(@"WholeWord: %i", [findObj matchWholeWord]);
@try
[findObj executeFindFindText:findText
matchCase:NO
matchWholeWord:NO
matchWildcards:YES
matchSoundsLike:NO
matchAllWordForms:NO
matchForward:YES
wrapFind:WordE265FindContinue
findFormat:NO
replaceWith:replaceText
replace:WordE273ReplaceAll];
@catch(NSException * e){
NSLog(@"Search Found:%i",[findObj found]);
NSLog(@"Search Content:%@",[findObj content]);
[pool drain];
return 0;

The replay answer
Advertisement
DavidMan wrote:
So, what is your suggestion?
Do it in pure AppleScript.
Whom to complain? Microsoft or Apple?
I'm not sure. All this stuff was new with Office 2008. It might work better with Office 2011. I would definitely ask on the Mac Office forum to see if anyone there knows any more: http://www.officeformac.com/productforums/

Go to See the other 4 answers

Microsoft Word API for Mac OS: Troubleshooting the Find/Replace function

Category:DefaultRelease time:2015-10-11Views:130

In my previous topic at http://discussions.apple.com/thread.jspa?threadID=2623068&tstart=0 we found out the way to connect to the Ms-Word from Objective-C through ScriptingBridge. The connection works and the given text can be found and replaced usin[More]

How can i use microsoft office on the mAC - what app do i purchase? help?!!

Category:DefaultRelease time:2015-10-11Views:130

how can i use microsoft office on the mAC - what app do i purchase? help?!!What aspect of Microsoft Office? Office is a suite of programs... Word, Excel, Powerpoint, etc. You've got several potential options. Libre Office and Open Office (both google[More]

How can I use Microsoft Access on my Mac? Boot camp?

Category:DefaultRelease time:2015-10-11Views:130

How can I use Microsoft Access on my Mac? Boot camp?Running Windows or using a suite such as Libre Office. It is similar to Office 2007 for Windows, but runs on a Mac, and contains a database manage that is Access compatible.Read other 2 answers[More]

How can I use Microsoft Access on my Mac?

Category:DefaultRelease time:2015-10-11Views:130

How can I use Microsoft Access on my Mac Pro?Welcome to Apple Support Communities Microsoft Access isn't available for OS X, so you can't use it. If you need it, you have to install Windows on a virtual machine. On a virtual machine, you can install[More]

So when I installed the most recent updates for microsoft office 2011 for mac, my ical info disappeared.  Still have the info on my Office calendar but it's no longer on ical.  It's also been removed from my phone.  How can I get outlook to sync with ical

Category:DefaultRelease time:2015-10-11Views:130

When I installed the recent updates for Microsoft Office 2011 for Mac, my iCal calendar was wiped out, as was the calendar on my iPhone.  I'd rather use iCal than Office and was attempting to phase Office out altogether.  Now, all of my information i[More]

Microsoft Outlook 2011 for Mac sync Contacts and Calendar issues

Category:DefaultRelease time:2015-10-11Views:130

OK, so I have a Macbook Pro with OS X Mountian Lion. I have Microsoft Outlook 2011 for Mac installed. Asked @BlackberryHelp on Twitter how to sync my Blackberry Torch with Outlook as it seems to default to using the builtin Apple Contacts and Calenda[More]

While trying to save a word document (Microsoft Office 2011 for Mac) in PDF, there is a section of the header or footer which is always missing!! Could anyone please tell me hot to fix this problem!!??? It works perfectly fine on my friends Mac!!

Category:DefaultRelease time:2015-10-11Views:130

While trying to save a word document (Microsoft Office 2011 for Mac) in PDF, there is a section of the header or footer which is always missing!! Could anyone please tell me hot to fix this problem!!??? It works perfectly fine on my friends Mac!!Easi[More]

How do I share microsoft software on a mac between users of the same mac?

Category:DefaultRelease time:2015-10-11Views:130

How do I share microsoft software on a mac between users of the same mac? New Mac Set up Microsoft tools on the mac but can't figure out how to share them between different logins we have setup on our computerHello FritzMills3, Thank you for using Ap[More]

Does Microsoft Entourage 2008 for mac work with the new Mac OS X v 10.7 Lion

Category:DefaultRelease time:2015-10-11Views:130

Does Microsoft Entourage 2008 for mac work with the new Mac OS X v 10.7 Lion? I am just about to install Lion just need to check to see if if my work e-mail will workSarah, Check this link: http://roaringapps.com/app:2533 It contains some issues that[More]

Topic: Microsoft's Silverlight for Mac. I wanted to video stream a movie via Verizon FIOS. It demanded Silverlight.dmg Macbok Pro refused to download from 3rd party supplier (CNET). How can I get this?

Category:DefaultRelease time:2015-10-11Views:130

Topic: Microsoft's Silverlight for Mac. I wanted to video stream a movie via Verizon FIOS. It demanded Silverlight.dmg.  Macbok Pro refused to download from 3rd party supplier (CNET). How can I get this from Apple?  The Verizon FIOS video website was[More]

Is there a version of Microsoft Access for the Mac computer

Category:DefaultRelease time:2015-10-11Views:130

I was wondering if there was a version of Microsoft Access for the Mac computer.  Most of the databases I have on my old computer are in Access and I need to be able to open them on my new Mac Book. Full Disclosure as per Apple Support Communities te[More]

Hot
hi, firstly my ipod touch is working fine in itunes. i reformated my computer so i lost all my old drivers ect ect, so now my ipod shows up as an image device. i have reinstalled itunes several times and installed apple mobile device but still doesnt [More]
We have a need to create a service purchase order (item category 'D') with one line item using account assignment 'P'.  We're creating as a 'limit' Purchase order and intend to create more than one service entry sheet. For example - the total expecte [More]
I have a pdf with many typewriter text boxes in it.  I now need to change those font colors...is there a way to do it all at once without going box by box to change the font color?Depends upon Platform the method but what you need to do is while in E [More]
Im very frustated and dissapointed because I pay for Unlimited Latin America Landline like three weeks ago but since this day I wasnt be able to call to my country Peru. It always says "the phone number is currently busy". I check my skype accou [More]
I downloaded an album from itunes yesterday. When I put the album on my ipod, the songs downloaded twice. One song plays and the other one doesnt. On my ipod, it doesnt give me the option to delete it, but the other songs do. When I plug my ipod into [More]
my iPhone does not show up on my home computer when I connect to iTunes. It does show on the office computer. Suggests please.Type "apple mobile device service" into the search bar at the top of this page by "support".Read other 2 answ [More]
Revision: 8563 Author:   [email protected] Date:     2009-07-14 14:47:50 -0700 (Tue, 14 Jul 2009) Log Message: When integrating TLF Build 468, the scrapToPaste() method of PasteOperation needs to be replaced by textScrap.clone(), not just textScrap. [More]
Can someone tell me the best way to produce a flowchart of staff members so that when you move the mouse over the staff member's name, their photo appears. Ideally, I'd like the photo to appear in the same place on the page each time. The flowchart I [More]
Hi, We have an C++ application which is compiled with Sun compiler 5.3 which comes along with Forte6 Update2. The application is compiled and linked on Solaris 9 platform. Will there be any issues while running this application on Solaris 8? Are appl [More]
When i try to backup my n80 via Nokia suite i receive error message on 1% "Connection to phone was lost.Please reconnect and restart backup.".I try to backup via blouetooth and USB cable that comes with n80 (CA-53), same problem! Windows XP Pro [More]