Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Location
    Connecticut, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Automation from Client Side Script (Word 2000/XP)

    Hi All,

    I'm having a problem that is a little hard to nail down. If necessary I can post an example, but it'll probably take me an hour just to strip down the code to the bare essentials to demonstrate the problem so I thought I'd see if anyone had encountered this problem in a general way.

    I'm using script in an HTA page (client side javascript) to automate MS Word (2000/XP). Basically the javascript...

    1. Creates an instance of Word.
    2. Runs a macro (defined in a startup template).
    3. When the macro is done does some other processing.

    The client side code is something like this:

    //processing...
    var wd = new ActiveXObject("Word.Application");
    wd.Visible=true;
    wd.Run(macroname, inputpath, outputpath, htmoutputpath, chapterfilelist, tocfilename, doctitle);
    wd.Quit();
    //more processing

    If I take out the wd.Visible=true then the macro runs 90% of the way through then stops. Not only does it not return an error - it never returns control back to the calling program. Also, if you look at the Task list it shows it chewing up the processor cycles (99%). I let it run for a half hour before I gave up and wacked it.

    Now if I leave the wd.Visible=true in then it all works as programmed.

    It appears to be hanging on this line in the Word Macro...

    ActiveDocument.SaveAs FileName:=FixPath(htmtargetdir) & TOCFileNameHTM, FileFormat:=wdFormatHTML, _
    LockComments:=False, Password:="", AddtoRecentFiles:=False, _
    WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
    :=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
    SaveAsAOCELetter:=False

    Anyway, that is just one line to save the doc as an HTML file. I tried stripping the macro of all references to ActiveDocument (using an object variable returned from the call to Documents.Add), but this didn't appear to make any difference.

    Anyone encounter something like this before? I've already spent a few hours trying to figure this one out. Figured it might be time to see if anyone else can shed some light.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word Automation from Client Side Script (Word 2000/XP)

    I had an issue once with Visible or not Visible, but I cannot remember what it was. Very helpful. <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

    I'm curious how you are determining this: "It appears to be hanging on this line in the Word Macro..."?

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Location
    Connecticut, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Automation from Client Side Script (Word 2000/XP)

    <<I'm curious how you are determining this: "It appears to be hanging on this line in the Word Macro..."? >>

    The hard way! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Actually, the "real" macro generates a lot of output files so just by looking at which files get created and which don't I can tell that this is the line. If I recall I also removed that line and it worked, but I'd have to double check that.

    Again if necessary I can try to post a sample to duplicate the error. I was just hoping someone might have seen this and I could avoid the extra work.

    If I don't see anything then I'll repost with a simple sample.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Automation from Client Side Script (Word 2000/XP)

    Have you got another PC to test on -- one with more RAM. I'm thinking system resources. Just a long shot, though.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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