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
iMac OSX Snow Leopard. Windows XP. Can anyone help me resolve this. I have installed Windows XP using Boot Camp. The Windows folder is 31GB using FAT32. Windows can read from the Mac disk, but cannot write to it (I get an ACCESS DENIED) error. I have [More]
Hello, I'm quite new in Java. I have an application with GUI. When I'm using Eclipse version 3.4.0 to run the application, all it is working perfect. But after I generate the jar from Eclipse, using the manifest file option from there and added the P [More]
Is it possible to write a dial-up connection programme in Java? It would also be interesting to know whether there exist some specs on the modem api. thank you lukaTry the comms api http://java.sun.com/products/javacomm/Read other 2 answers [More]
What's the best way to remove html tags from a string (i.e. user input)?Can you give an example? You can do substring, if your passing spaces between pages you can do a trim to the variable. Also look at the indexOf(). Look at methods relating to jav [More]
I went on a trip out of the country for a week and kept my phone in airplane mode the entire time. Now that I am back in the country it only says searching andy cellular won't connect. Please helpContact your carrier.Read other 2 answers [More]
There is no + (plus sign) in the Calendar app so I am not able to schedule an event?I noticed they got rid of that feature now if you do not have iCould on. You simply have to re-enable iCloud for Calendars in the iCloud section of Settings. This won [More]
For selecting all the text in a dynamic text field. I had problems with the code below losing focus after the selection. I was chasing my tail like a mad dog trying to figure it out. I embedded the text field in a movie clip, published it as HTML, tr [More]
Dear members: I have some questions I would like to have answered prior to deciding whether I should invest on Ligthroom and thought I would post them here to get some input. They are: 1. Is metadata assigned to a DNG file by Lightroom interchangeabl [More]
Hi, I have made a portal application using EPCF in eclipse for EP60 SP2 but get the following error in the portal: ”com.sapportals.portal.prt.component.PortalComponentException: Error in service call of Portal Component Component : RIGSenderParProjec [More]
hello guys!! i'm just newbie in flex, and cant figured out how to manage loaded modules to set who's on top of each other. if i load one module then loads another one, the last module loaded is the one on top what i want to happen is when i click on [More]