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
I have copied required JAR and ZIP files into the /lib directory of Java Web Server. Classpath is also pointed to that. I am getting the first screen of JSP with menu on left side but I am getting "Error Message: oracle/jbo/html/databeans/Res" i [More]
I have a new Window 7 Premium Home Edition,Model: Inspiron 560. It came with a 30 day free trail of McAfee Anti-Virus Protection, which expires in less than three days. Roughly, two weeks ago, I received in the mail from QVC, a DVD, named PC Treasure [More]
Hi, Can any problem to occur while-and-after I'm installing Cisco OS and CallManager 4.2(3) on the MCS that currently doesn't have network connection (no network cable plugged into the MCS's NIC1). When I'm writing the word 'problem', I mean the infl [More]
Hello I am currently investigating a dual data centre design running in active/active mode. The data centres will each have connectivity to our WAN (MPLS) and to the Internet. They will have also have dedicated links to each other for site replicatio [More]
Hi Experts, I have a scenario wherein,a General project is created followed by sub folders containing .hbdprocedures,.hdbtables,schemas etc. I had created a similar folder inside the project which was blank but later deleted it .After that activated [More]
Hi there, This website belongs to our school project and we are getting reports from the teacher assistance and the professor that the website is not funcationing properly. They are saying the menu on the bottom of the page is not showing so they can [More]
Is it possible to disable object cache globally i.e. any deref results in update from db ? Message was edited by: tiaanwNot currently. We may have this feature in future.Read other 2 answers [More]
I'm bout to purchase a MBP, 1.83 Ghz model through an authorized Apple retailer. My question is fairly simple. This is an older model (how old, I am not sure), therefore I would assume the likelihood of it having some of the major issues in quality w [More]
I'm fed up. I've filled out their form 6 times. The first few responses from them were worthless, saying oh you need to fill out this same form more detailed but not letting me know what they needed. Well I'm so sorry if I cannot recall the month and [More]
Like the question suggests, I'm thinking about purchasing one of the new 27'' iMacs and I'm wondering if I'd be possible to repartition the 3TB fusion drive to use the 128GB SSD part only for the OS.Thanks a lot for this fast and helpful reply! €dit: [More]