InDesign CS6 and C# (Regular expression)

GREP does not work
//CODE
InDesign.Application InDesignApp = (InDesign.Application)Activator.CreateInstance(Type.GetTypeFromProgID("InDesign.Applicati on"));
InDesignApp.Activate();
//Create Document
InDesign.Document InDesignDoc = InDesignApp.Documents.Add();
//PageWidth
InDesignDoc.DocumentPreferences.PageWidth = Convert.ToDouble(numericUpDown_width.Value);
//PageHeight
InDesignDoc.DocumentPreferences.PageHeight = Convert.ToDouble(numericUpDown_height.Value);
InDesignDoc.DocumentPreferences.PageOrientation = idPageOrientation.idPortrait;
InDesignDoc.DocumentPreferences.PagesPerDocument = 50;
InDesignDoc.DocumentPreferences.StartPageNumber = 1;
InDesign.Page page = (InDesign.Page)InDesignDoc.Pages[1];
InDesign.Layer layer = (InDesign.Layer)InDesignDoc.Layers[1];
//Place *.docx in Document
page.Place("C:\\sample.docx", new[] { 0, 0 }, layer, false, true);
InDesign.Document Doc = (InDesign.Document)InDesignApp.ActiveDocument;
//Clear the find/change grep preferences
InDesignApp.FindGrepPreferences = idNothingEnum.idNothing;
InDesignApp.ChangeGrepPreferences = idNothingEnum.idNothing;
//Set the find options
InDesignApp.FindChangeGrepOptions.includeFootnotes = true;
InDesignApp.FindChangeGrepOptions.includeHiddenLayers = true;
InDesignApp.FindChangeGrepOptions.includeLockedLayersForFind = true; ;
InDesignApp.FindChangeGrepOptions.includeLockedStoriesForFind = true;
InDesignApp.FindChangeGrepOptions.includeMasterPages = true;
//Regular expression for finding an email address
InDesignApp.FindGrepPreferences.findWhat = "(?i)[A-Z]*?@[A-Z]*?[.]...";
Doc.FindGrep();
//Apply the change to 24-point text only
InDesignApp.FindGrepPreferences.pointSize = 28;
InDesignApp.ChangeGrepPreferences.underline = true;
Doc.ChangeGrep();
//Clear the find/change grep preferences
InDesignApp.FindGrepPreferences = idNothingEnum.idNothing;
InDesignApp.ChangeGrepPreferences = idNothingEnum.idNothing;
//END CODE
where am I wrong?

For the beginning you're in the wrong forum, this is the place for C++ plugin development.
Whether using C# (a strongly typed language) to access the scripting API (which prefers weakly typed scripting languages) is wrong lies in the eye of the beholder.
Then you should add some more prose. At least rephrase the problem, why you think that grep does not work. Does it find nothing, or too much? Do you have no visual feedback of the operation? Does it throw an error? Does it just clear the findings?
From just looking at your script:
- Why do you need two document variables?
- You set the find preferences after you invoke FindGrep()
- the comment says 24 point but the value is 28 point. Are you sure about either, the actually applied value might be 23.98?
- the only purpose of FindGrep() is to find and yield the findings for further processing by a script. Use the result or remove the statement. Doc.ChangeGrep later on implies a FindGrep.
- You only set the underline flag, but there are many more attributes involved with underlines (depends on the effective style) such as underline color or underline stroke width and so forth.
- the findWhat value ends with 3 dots, it might not be what you want.
- The question mark in "*?" is redundant. Twice.
- I won't even try to understand more of your grep expression. For such issues there is the interactive mode of InDesign called "UI". It has many fancy windows, dialogs and panels where you can experiment with various settings before you turn them into a script. I'd especially recommend the Find/Change dialog (you can try and tweak the grep string until it breaks) and the underline options dialog of the character attributes panel.
At least in JavaScript you can later on dump the "properties" property of any native object in order to copy the working values into your script. So you also make sure you don't miss the better half of them. It should not be too hard to translate that JSON into C#.
e.g. type this in ExendScript Toolkit console
$.writeln(app.findGrepPreferences.properties.toSource());
$.writeln(app.selection[0].properties.toSource());
Finally
- consider to set the changeTo value to an appropriate expression.
- consider to use the dynamically evaluated grep styles instead of that script.
- Probably I missed a few points.
Dirk

Similar Messages

  • How can i download InDesign CS6 and not CC from your website?

    how can i download InDesign CS6 and not CC from your website?

    Are you a cloud subscriber, or are you looking for a perpetual license or trial version?

  • Ok i have indesign CS6 and all files are stored on a 10.7.5 MAC server.  This just started happening.  When I open a file indesigns is creating a textfile in the same folder?  I need some help on this.

    Ok i have indesign CS6 and all files are stored on a 10.7.5 MAC server.  This just started happening.  When I open a file indesigns is creating a textfile in the same folder?  I need some help on this.

    Ask in the ID forum and be much more specific about your configuration. there could be any number of reasons why manifests, temp files or restore files are created.
    Mylenium

  • Can we get Adobe InDesign CS6 and use CS5?

    Hi There,
    We currently have 4 license of InDesign CS5 that comes with Adobe Creative Suite CS5.
    Also an Adobe Product Premium CS5.5. We now need to get an extra license for InDesign CS5 for the Adobe Product Premium CS5.5 machine.
    I noticed Adobe now sells CS6 versions only. Can we get Adobe InDesign Cs6 and have down grade right to use InDesign CS5?
    Best Regards/Allen Chen

    Bob Levine wrote:
    Alternatively move to Creative Cloud.
    But that means buying cloud subscriptions for all seats so everyone is on the same version rather than buying one seat to downgrade. I agree that inthe long run this is probably a better solution, but it may cost more up front.

  • Updating an index in InDesign CS6 and retaining commas

    I have an index in a book document I am creating in InDesign CS6 and as I add imagery to the text the page numbers change so I go to the index panel and generate index which overrides the previous version. This has been working perfectly but my last attempt caused the commas between the page numbers to turn into dots above the base line. I wonder if anyone knows how I can solve this problem and turn them back into commas. In the 'more options'  section of teh index panel I have specified commas as the page separators but this isn't changing them back to commas in the index,
    I would be very grateful if anyone can help me with this.

    Thank you - I can't see where this has happened as it seems to be applying the footnote superscript style to the index. I can restyle the index after each time I regenerate it as a work around. Thank you for your help.

  • I have a problem with indesign cs6 and my epson 3880 on mac

    I have a problem with indesign cs6 and my epson 3880 on mac.  I need an older version of indesign but do not have a serial number....any suggestions?

    I see then I believe Kglad's advice is on track with starting with updating your printer drivers.  I have also moved this discussion over to the InDesign forum as the Users in this forum likely have additional suggestions.
    Also if you can please turn off your e-mail signature if you want to respond via e-mail.  Your responses are going to a public forum where the information is accessible by anyone.  I have edited your previous response to remove the signature.

  • I used a Photoshop file as my background for a brochure in InDesign CS6 and when I print it thru eit

    I used a Photoshop file as my background for a brochure in InDesign CS6 and when I print it thru either InDesign or via exporting it as a pdf it always has a white border.  How can I eliminate this?  I was on the phone with a tech for an hour and fifteen minutes.  The answer I was given is that InDesign places white borders automatically.  Need help, the white borders do not coincide with a mostly black background.

    I am not certain you understood the technical support person from wherever you shought help.
    ID will simply output what you tell it to. If you have designed a brochure that has a bleed and your PS file extends into the bleed, and you output a PDF with the correct settings, and send it to a service bureau (not certain about instyprint) that can print that size with bleeds, then trim it to size...phew. Seems like a run-on sentance there.
    As for printing to the edge of a piece of paper on a local printer that supports it, you need to set up the printer to do so. At least that's how it has worked with the borderless printers I have used.
    If you need an inexpensive brochure printed, try Quantum Digital. As long as you design it to their specs, it is a quick turn, the printing is fine for most inexpensive jobs, and they are pretty inexpensive. Offset quality they are not.
    But your file better be constructed properly.
    Take care, Mike

  • I just got InDesign CS6 and am running it on an iMac and I know the license is good for two computers which will come in very handy for me.  How do I set it up to access it from my second iMac?

    I just got InDesign CS6 and am running it on an iMac and I know the license is good for two computers which will come in very handy for me.  How do I set it up to access it from my second iMac?

    I just had an afterthought, Peter, if I could bother you further; if the downstairs iMac that I want to access it from is in my wife's name and not mine (even though I'll be the one using it on her computer) does that affect anything or can I simply load the software straight into her computer without any complications?

  • Sharing files between InDesign CS6 and InDesign CC

    Can a user of InDesign CS6 and a user of InDesign CC share files without having to save as idml?

    Whoop. Hit send too soon.
    The CC user has access to CS6 as part of the subscription and should be using that to share files with someone who only has CS6.

  • Deactivated Indesign CS6 and then uninstalled from Windows 7 - now want to re-install CS6 on Windows 8. Please advise procedure and where to download from ?

    Deactivated Indesign CS6 and then uninstalled from Windows 7 - now want to re-install CS6 on Windows 8. Please advise procedure and where to download from ?

    I am looking for the exact same information! Someone, help? I didn't realize when I gave them so much money that Adobe has the customer support of a snake with its tail in its mouth...

  • Indesign CS6 and CC

    I'm building an app for a client. I'm working on InDesign CS6, and my coworker will be working on InDesign CC. Will this be compatiable, or will both computers have to be on InDesign CC?

    or you may use that CC on your computer as well:
    http://forums.adobe.com/thread/1347241

  • InDesign CS6 and Arial Narrow

    I have been using CS5, had problems with the Arial Narrow font not showing up as four variations but only one, and eventually got it resolved somehow so that I had a separate font listed as Arial Narrow in the font name drop down list and four variations listed in the other drop down list (all distinct from the Arial font with its four variations). I know I deleted a lot of AdobeFnt*.lst files. I know I tried the hotfix that I found through a lot of Google searching, but it said it didn't apply to my system. Beyond that, I don't know what fixed the problem and I remember it feeling like a lot of trial and error, but eventually I got it solved.
    A few days ago I installed CS6 on my system for the first time, and now I've got the same problem back again. I've spent all afternoon trying to resolve it but without any success.
    I have three sets of TTF files for Arial Narrow, each set with four files for regular, bold, italic and bold italic. One set is version 2.20, one is version 2.37 and the other is version 2.40. My system is running Windows 7 Professional, 64-bit.
    Does anyone have any idea of what will fix this problem on my system? I have a lot of InDesign documents that use Arial Narrow, so now whenever I open one of them, I have lots of missing font references. If I could get Arial Narrow reinstalled properly once again, they'd all go away.
    Thanks!

    This problem is due to the offending fonts having the wrong "Preferred Family" and "Preferred Subfamily" names and it can be corrected using a Font Editor, such as the free version of Type light which can be downloaded from http://www.cr8software.net/typelight.html.
    The process I found to work (in Windows 8 with Adobe Indesign CC and Office 2010) is as follows:
    Open a File Explorer window and go to the system font library at C:/Windows/Fonts and double click on the Arial font (this has a special icon indicating that it contains multiple subentries)
    Copy the fonts for Arial Narrow, Arial Narrow Bold, Arial Narrow Italic and Arial Narrow Bold Italic to a new folder on your desktop
    Edit each of these copies using your font editor and change the  Preferred Family and Preferred Subfamily names (in Type light use the menu option Font>Names... then click the Advanced button)
    The Preferred Family should be changed to Arial Narrow and the Preferred Subfamily should be either Regular, Bold, Italic, or Bold Italic as per the particular font you are editing (While you are there you could also make similar changes to the Arial Black font which has the same problem - in this case, make Preferred Family Arial Black and Preferred Subfamily Regular)
    Save each font file back over the top of the one in the folder on the desktop (Save and replace) then open a new File Explorer window for that folder and drag the changed fonts back into their orginal location at C:/Windows/Fonts/Arial
    Open a new File Explorer window and do a search on the C: drive for all instances of AdobeFnt*.lst then delete all of them
    Restart your computer

  • InDesign CS6 and CC hang constantly in Windows 8 x64

    Id anyone else experiencing a similar problem? If I do anything at all in InDesign, the application will "hang". I can still move my cursor, it does not crash, I can still see what text block or other item I have selected, but I can't do anything at all with it. Oddly enough, if I press "esc" one time, I will get the frame handles, and I am then able to do whatever I wanted to do with it. If I deselect it, the select something else (or the same item again) it does the same
    thing. I get a box around the item, but can't do anything with it. I can't move it, I can't select the text, I can't select anything else. BUT ... if I hit "esc" I get the handles, and can then do what I want. This is extremely annoying. I have both CS6 and CC installed on my desktop here at home, using Creative Cloud. Both versions exhibit the same issue, regardless of file (they all do it, even a brand new document with only one word placed). At work, I have a desktop that is running Windows 7 x64, and they both work fine. The issue seems to only be happening on my desktop here at home, running Windows 8 x64.
    Any thoughts would be extremely grateful. Thanks!

    Thanks. I periodically check for new drivers and have indeed installed the latest drivers. Last night, just as a check to see if it was a problem with new drivers, I installed an older version of the driver and it still behaved the same, so I reinstalled the newest drivers. I'm going to get with Wacom's support team and see if there is any known issues from their end. Thanks for your response. Double-checked this morning, and the problem does not exist here at my office where I have the nearly identical set up, with the exception of running Win 7 x64 instead of Win 8 x64. Same model tablet, same drivers from June of this year, same file. It seems to be an issue with Wacom, Win 8 and InDesign. I don't have any issues with Illustrator CC, PS CC or LR 5.

  • InDesigns CS6 and CC Crash

    About every two months I have to uninstal and reinstal InDesign. It will crash when I open it and won't open again until I uninstal it and the reinstal it and then It'll work for roughly two months before I have to do it again. I had this problem with CS6 and CC. And it's only on the Mac osX 10.8. The Windows 7 runs great.
    Does anyone else have this problem?
    Is there a fix?
    Does Adobe know about the problem?

    Normal I'd take that answer, but I don't think that's it. I have a 2010 MacBook Air with CC it's crashing on, at school last year my 2009 iMac had the same problem with CS6 and at work my brand new (bought last month) iMac has the problem with CS6. I don't think that it's a program conflict, the only software all three have in common are Adobe and Apple's stock programs: iMovie, Garageband, etc.

  • Indesign CS6 and Windows 8

    Indesign CS6 is extreamly slow in Windows 8 espeially in editing Text.

    And what do you expect us to tell you? If you have problems, you need to explain them properly and provide the necessary info - in the ID forum.
    Mylenium

Maybe you are looking for

  • Display an HTML page within a a panel

    I want to create an applet with multiple panels, and have the ability to display HTML pages within these panels. These will be HTML pages with formatting complex enough that the JEditor display won't be able to handle them. I experimented with showDo

  • Recon account ready for Input-Not possible to change during MIRO

    Hello We are on ECC 6.0 System does not allow users to change Vendor Recon A/c during invoice verification through MIRO. Recon A/c field is greyed out under Details tab in MIRO. Recon Account has been declared as Ready for Input and Alternative Recon

  • Easily drag n drop to a cd-rw

    with a pc you can easily put a cd-rw disc into the drive and start draging files or picture to it to save. Is there a way to do that on the macbook pro without going into the disk utility every time you put it back in the drive. Or do I need to downl

  • All of the sudden I am having a lot of trouble with Safari.

    Rather then trying to explain what Safari is doing, are the Installed plug-ins updated when I do a "Apple>Software update?" I need to update Shockwave Flash 10.0 r45. Any idea how to update this other then using the download icon? I can't even find t

  • How to reinstall Aperture purchased online, after changing AppStore?

    After upgrading to mountain lion I have to reinstall Aperture, which I purchased from the Thailand AppStore. I now have moved to the Indonesia AppStore and cannot access / reinstall Aperture, as it doesn't list under purchases in my Indonesia AppStor