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
Please let me know if there is a way to adjust the font on a fillable field so that whatever is keyed in the field will fit. We can do this in Word with autofit and were hoping that there was a way to do this in Acrobat. We are using Acrobat Pro 7, b [More]
hello, I am running windows 7 64 bit on boot camp. I have a 27'' imac with the ati radeon HD 4850. The problem is the driver of that card is dated to 11/24/2009 which is very old! There is a new driver that ATI proposes, which is released in 2011 htt [More]
After I upgraded safari this morning I noticed when you go over your bookmarks, (the ones above the tabbed browsing) the arrow (mouse pointer icon) disappears. If you click in main window you get it back. It don't happend all the time, but often enou [More]
hello SAP Gurus,     how u can test the EDI?    Thank you very much. Regards, Vijaya.Hi, Testing of EDI can be found in the following link. https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8f3ec890-0201-0010-2797-dea114b3b176 Elect [More]
Everyone a Answer? Every time when I print a PDF as  A3, I must first open and close extends menu (I make no modifikation). Otherwise it print A4 size on A3 sheets Thanks an best regard GuidoTHX. Best Regards GuidoRead other 3 answers [More]
Hi Friends When i try to use transaction xslt_tool the following error appears "You are not authorized to use transaction xslt_tool". Can anyone give  the Authorization object  for  transaction  xslt_tool, Regards. WishvaGive access to the trans [More]
I've just replaced an older 5508 with two new 5508 controllers that we wanted to run in redundancy mode.  I've followed the directions here: to configure my units.  at this time i have my management, and redundancy management IP addresses configured [More]
Im trying to connect But I cant because My built in ethernet is greyed out. Help please! A screenshot if it helps:10.4 is Tiger, 10.2 is Jaguar.  Which one do you have?Read other 3 answers [More]
Hello everyone, Just curious. is it possible to have an Xserve RAID volume shared accross a fiber channel network? Set up will be one RAID, 5 powermacs (all with FC cards) and connected to a fiber channel switch. Can i just share the RAID volume (wit [More]
Hello, I can't use quicktime, it gives me the error " Quicktime player requires windows 2000 or later" and changes all my icons into super size. I have windows 2000 and I've disabled all in the compatibility tabs (as it requested) and this does [More]