Results 1 to 2 of 2

Thread: Inject VBScript include and function call into ExtJS 4 w/ MVC

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ext JS Premium Member antonye's Avatar
    Join Date
    May 2010
    London, UK
    Vote Rating

    Question Inject VBScript include and function call into ExtJS 4 w/ MVC

    Strange request, but bear with me...

    We need to do some spell checking on an internal ExtJS application.

    The key there is "internal" which means we have a known platform of Internet Explorer with Microsoft Word installed, and one of the "nice to haves" is to use the user's own dictionary in Word.

    I have a nice little piece of code which I've used a lot previously to do exactly this... but my problem is that it's in VBScript so I will need to either inject this script into my page at some point, or a reference to an include, and then call that function, all in my ExtJS 4.1.3 MVC app.

    What is the best/recommended way of doing this?

    The VBScript function is very simple, and is currently in an include file, and consists of the following code. Remember that this needs to stay as VBScript to interact with the Windows environment and launch Word.

    function Spelling_Grammar(TextValue)
         Dim objWord, objDocument, strReturnValue
         Set objWord = CreateObject("word.Application")
         if objWord IS NOTHING then
              MsgBox "Microsoft Word is not installed!" & vbCr & "This is required to check spelling.", vbCritical, "Error"
              objWord.WindowState = 2
              objWord.Visible = False
              'Create a new instance of Document
              Set objDocument = objWord.Documents.Add
              'Return checked text and quit Word
              strReturnValue = objDocument.Content
              objDocument.Close False
              objWord.Application.Quit True
              MsgBox "Spelling Check Complete!", vbInformation, "Spelling"
         end if
    End function
    You can call the function very simply from a button or image using the following:

    onClick="document.all.boxId.value = Spelling_Grammar(document.all.boxId.getText())">
    So ideally I would like to include a reference to my SpellCheck.vbs file (somewhere) in my ExtJS code, and then call the function as above.

    Any thoughts appreciated!

  2. #2
    Ext JS Premium Member antonye's Avatar
    Join Date
    May 2010
    London, UK
    Vote Rating


    So I've had some time to think about this and have managed to do pretty much the same thing in JavaScript rather than using VBScript:

        handler: function () {
            var box = Ext.ComponentQuery.query('#commentaryText')[0];
            var wordApp = new ActiveXObject("Word.Application");
            wordApp.Visible = false;
            wordApp.WindowState = 2;
            wordDoc = wordApp.ActiveDocument;
            wordDoc.Content = box.value;
    This works, but the only problem is that the text returned from the wordDoc.Content.Text gets stripped of some formatting such as carriage returns, when it is set into the textArea.

    I'm trying to figure out where that is happening (it's not the returned text) and to see if I can work round this, but otherwise I think I've just about solved it!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts