• Open documents and start macros in doc. (IE 6.0.2600.000)

    Home » Forums » AskWoody support » Questions: Browsers and desktop software » Internet Explorer and Edge » Open documents and start macros in doc. (IE 6.0.2600.000)

    Author
    Topic
    #376800

    Problem:

    1:
    Opening an Office (Word) document with a http-link results in opening the file as a temp file. I want to open the file such that it is editable. How to set IE/Registry to do this?

    2:
    Opening an Office (Word) document with a http-link that contains a macro that shall start when the document is opened, does not work. How to set IE/Registry to do this?

    3:
    Starting a Word template(.dot file) with a http-link does not work. Only the .dot file is opened. How to set IE/Registry to handle .dot files as Word does it?

    (We are using Microsoft Office 2000, Word 2000 and SharePoint Portal Server for archiving and controlling documents and this system is based on http – links.)

    Would verry much appreciate solutions to my problems.

    Thanks!

    Regards
    Bj

    Viewing 1 reply thread
    Author
    Replies
    • #618694

      Are these Word files on a in house server or out on the internet?
      Also do you in fact have write access to these servers?

      DaveA I am so far behind, I think I am First
      Genealogy....confusing the dead and annoying the living

    • #618739

      Some of these symptoms can be caused by the document opening in IE with a Word toolbar rather than in the Word application. I believe this is controlled by the Browse in same window setting that you can find in the File Types dialog. (Many past illustrations here in the Lounge.)

      With respect to the templates, you can use VBScript to Shell the template into a new document. I have posted the code here before for both Word and Excel.

      • #619400

        Thanks!

        Status when opening with a http address:
        In the Application title bar at the top of the window it is written: Document in Microsoft Internet Explorer – Microsoft Word. (The document is a temp file!)
        My standard Word toolbars are vissible.
        If I display the toolbar called Web, it is empty. (testing by inserting the field code FileName gives the same file name as at the top)

        If I use SaveAs, the document will be saved at the selected folder but the “Document in Microsoft Internet Explorer – Microsoft Word” is still in the window and the new one is diappeared.

        The setting in WinExplorer: Tools/Folder Options … “Brows in same” window is not marked

        **************************************
        Is this any solution?:
        If I set the registry key: HKEY_LOCAL_MACHINE/SOFTWARE/Classes/Word.Document.8/BrowserFlags to a Value: a (10), the document will open in Word in read only mode and will be editable when Read Only is removed.

        The same setting is effective for PowerPoint documents as well, then in another key which is: HKEY_LOCAL_MACHINE/SOFTWARE/Classes/PowerPoint.Show.8/BrowserFlags Value: a (10)

        BUT! Using this setting in the registry the document opens OK, but a code inserted in the “Private Sub Document_Open()” procedure, which shall start when the document opens in order to retrieve a version number from SharePoint, does not start.

        Are there other settings in the registry that controls this behaviour?
        There may also be a setting for how the browser treats a document containing macros or documents that are based on a template (.dot file) located in the Workgroup-templates catalog, located another place.

        Using Microsoft TecNet and other help, are very difficult use in order to find explanations and solutions to these things.

        **********************************************’

        Regarding VBScript to Shell the template. This I would appreciate very much to get hold of. It may solve all these problems. I shall search for it, but if you could give me a word(s) for which to search for it would be most helpfull.

        Thanks a lot!

        Regards
        Bj

        • #619404

          If Browse in Same Window is unchecked, I don’t know why it is browsing in the same window! But IE behaves in mysterious ways sometimes.

          Regarding BrowserFlags, this might have been discussed before. I haven’t researched them recently.

          One of the posts regarding VBScript/template options is Post #130411. It’s not on the IE board; sorry if you’ve been scouring this one.

          • #619412

            Hi,

            Thanks!

            The document opens in Word (sorry if I have explained myself wrong). But the procedure “Private Sub Document_Open()” located in the module “ThisDocument”, does not start when the document is opened from IE or with a http address. It starts if I opens the document using Windows Explorer.

            Regards
            Bj

            • #627443

              I am having the same problem. We have a number of Word and Excel documents we would like to make available on our intranet. Everything work fine unless the document contains VBA. The VBA runs if I open the document through explorer. It also runs if I use Netscape (which is not our default browser). Any other suggestions?

            • #627873

              Thanks,
              though it is not a pleasure that you have the same problem.

              Microsoft has come with a SharePointPortal Server (SPPS) which “takes caere of” documents: control them with version numbers etc.. Also Microsoft supply VBA, for us to make documents based on e.g. Word templates. SharePoint functions like IE; the documents are stored on an URL address (http) and then the AutoOpen or DocumentOpen macro starts when opening a document from SPPS.

              I have asked other places but in vain. Hopefully someobe can give an explanation why the macro will not start. Security reason has been mensioned, but I have tried to set security to Low in Word without any changes.

              I’m waiting for a miracle?

              Bj

            • #628387

              OK. I did find something that works. If you create a shortcut to your word document and place the shortcut in the directory with the document, then change the link to point to the shortcut (.lnk) rather than the document itself, it works. I had to rename the shortcut after I created it or clicking the link just resulted in trying to open the shortcut itself rather than opening the document. But after renaming the shortcut and creating the link, it worked! However in my case, this required that the users be able to log into the server where the documents reside rather than just have access to the intranet (controlled by border manager). Hope this helps you more than it helped me!

            • #636849

              We have had a similar problem with making documents available over the intranet and getting startup code to run. In the end we created some JavaScript to explicitly open Word (using ActiveX), open the document and then run the startup macro on the document before making the application (and the document) available to the users

              Very convoluted but it works.

              The other solution may be to write a COM add-in to Word. I believe this then works every time – even through IE

            • #636991

              Would you be interested in posting a sample of that code for future reference? I’m attaching a ZIP file with a demo of the original problem and the other two work-arounds.

            • #637360

              Sure – the javascript is as follows:

              function loadDocument(documentName)
              {
              objWord = new ActiveXObject( “Word.Application” );
              objWord.Documents.Open(documentName);
              objWord.Run(“macroname”);
              objWord.visible = true;
              objWord.Activate();
              }

            • #637500

              Thanks! I’ve always used VBScript for this sort of thing and didn’t know how to create the object in JavaScript. (The equivalence with VBScript’s CreateObject is illustrated here as well. Easy to find once you know what you’re looking for. wink )

            • #665459

              Hi there – I know this thread is a bit old now, but I am very interested in being able to use the javascript you posted to open Word documents and have their document_open (or document_new in templates) subs run, but I know very little about Javascript.

              Could you possibly let me know how to use the code you posted within an html page, please?

              I would be most grateful.

            • #665461

              Beryl

              Try the code that Jefferson posted (as an attachment) using VBScript. He has attached a sample html page with a word doc and instructions.

            • #665463

              Andrew, I’d love to, but I can’t download the attachment? If I click on it, IE says the page is not available (!) and if I right click and ‘Save target As’ it starts downloading then brings up an error message saying it couldn’t download it and to try again later?

              confused

            • #665464

              PS Is the VBScript attachment I can’t get at the same as the javascript code that jsaliba posted? Because it was the javascript one I was interested in particularly …

            • #665465

              (Edited by jscher2000 on 01-Apr-03 00:20. ) Try this: create a new text file and paste this in, then save as a .html file and open it in the browser.

              Code:
              JavaScript Demo by JFS
              
              function docOpen(fldID)
              // Based on Post #204511 at Woody's Lounge by jsaliba
              {
              	var fldDocName = document.getElementById(fldID);
              	objWord = new ActiveXObject("Word.Application");
              	objWord.visible = true;
              	objWord.Activate();
              	objWord.Documents.Open(fldDocName.value);
              	//objWord.Run("macroname"); //use if the macro to run is not auto running
              }
              
              
              
              
              

              Demo: JavaScript Word Document Load/Macro Runner

              Find the file and then click the button to launch it in Word using JavaScript.

              Naturally, the file you use will need to contain a Document_Open or AutoOpen macro. Also, security restrictions that do not allow “unsafe” ActiveX controls to run will hinder the script, so you might get different results on your own computer and on an intranet server.

              Afterthought: If you never program in JavaScript/JScript, it might not be obvious that within the and tags, you use // to designate an inline comment, exactly as you would use ‘ in VBScript or VBA. If you already are thinking “Duh!” then never mind. smile

              Afterthought #2: You can test with the attached .doc, which contains both an AutoOpen and a Document_Open macro, each displaying a message box.

            • #665473

              Just as a matter of interest – I clicked on your test attachment to this post, and it opened fine – but it didn’t run the code! Is that because the lounge page is not set up with the javascript code?

            • #665477

              Hi, jefferson, thanks for the sample code. I know I’m being extremely thick here (and I must admit my javascript is very basic), but how do I phrase the link within the body text, to actually connect to the document, please?

              Ta muchly!

            • #665556

              Well, I went home earlier than you did yesterday (or should I say, this morning). The key is to do it step by step following my last message only. Ignore everything else and just do it in order, and all will make sense.

            • #665693

              Hi Jefferson – yes, I followed your instructions to the letter and the sample page these instructions produce works perfectly – but what I don’t see is how to apply this to a link on an existing page!

              As I understand Javascript, the bit between the codes goes at the top of the page, but what should the link itself look like, in the body? I don’t want fill-in boxes or buttons, just clickable text.

              Ta muchly!

            • #665700

              Gotcha:

              Does that work for your needs?

            • #665703

              Thanks, it looks like it should, and in fact it does open Word – but the document doesn’t open! I copied the code into the area (do I need the function loadDocument, by the way, or was that connected with your sample page?), and copied your suggested line, changing the filename and description to what I need, but it stops with Word open and no documents! It’s as if it can’t actually see the doc!

              Does the path have to be the full path? I hope not, because my code is currently as follows …

              …and if it has to have the full path it will cause problems!

              What am I doing wrong?! confused

            • #665903

              > Does the path have to be the full path?

              The path needs to be a path that Word will know how to open.

              > ../bankinfo/bankfile/staff/idea.doc

              So… I think this is not going to work without some futzing to create a full path. The browser is passing the relative path to the JavaScript interpreter, which doesn’t know what the heck it is and therefore doesn’t automatically translate it into a “real” path. JavaScript offers some help, though. For example:

              http://” + location.host

              run in JavaScript on this page should return “http://www.wopr.com”

              There is a location.pathname property that returns everything after the location.host, starting with the /, through the end of the document name for the current page (not including parameters, e.g., ?dogsname=rex&fixed=true).

              Parsing out the name of the folder represented by the .. in your path seems as though it would be a lot of work. In JavaScript. In VBScript, I’d throw that path at the Split() function to create an array of strings (element 0 would be blank, 1 would have the first folder, etc., and the UBound() would have the filename). I’d then try to figure out where the ../ elements lead in the path.

              JavaScript also has a string.split(delimiter) function, but I’m less handy coding this sort of thing in JavaScript. Maybe you can find some script ready-made online? Or if everyone uses IE, switch it all to VBScript.

            • #665958

              Sounds good, and since I do know what the string should be when starting with the http:// I was able to put that in – but it still won’t open the document. The string now looks like this:

              confused I’m really confuggulated now! confused

            • #665984

              Unfortunately we have now ascertained that ActiveX banned on all machines here (except mine, for some reason – I don’t know why!) so I won’t be able to use the Javascript route … I’m keeping a copy of the code for use on my own stuff, though!

              Which means I’m back to the method using a shortcut – does anyone know of a way to tell IE to just run a document without stopping and displaying the “Do you want to run this doc or save to your hard disk” message?

            • #666109

              > does anyone know of a way to tell IE to just run a document without stopping and displaying the “Do
              > you want to run this doc or save to your hard disk” message?

              Why, the answer is in the related thread, here: post 240214. Did that not work?

            • #666125

              > Unfortunately we have now ascertained that ActiveX banned on all machines here (except mine…

              While I’m no fan of downloading new ActiveX controls from strange web sites, it does seem to be throwing the Office baby out with the bathwater to disallow running already-installed ActiveX controls invoked from pages in the “Intranet zone.” Maybe someone can revisit this policy. Or are they saying they don’t trust the content on their own servers?

            • #666191

              No, it’s just that they either have to allow people to say ‘yes’ to running this particular ActiveX control with the associated risk that they will assume it’s alright to do so with external ones because they can run this one (yes, I know, they are assuming all our users are a little on the thick side, but then some always will be …) or change the set up for every machine in the place, something that would be considered too much like hard work just to allow one document to run from an intranet page!

              That second reason is why your other suggestion is not feasible for us, too – it would mean changing the setup for each individual machine and wouldn’t be considered worth the effort.

              As it stands, I’ve used the shortcut method and simply put a comment against the link, to the effect that they should choose ‘run from current location’ when given the choice.

              Life is never easy, is it?! sigh

            • #666208

              > …it would mean changing the setup for each individual machine…

              Just a registry setting; can be changed in the blink of an eye with a VBScript at logon. If you wanted to pursue that… even though it’s not your responsibility… I think a new thread would be in order. grin

            • #666214

              I think you’re right, Jefferson – a new thread would be in order, but I don’t think I would be able to persuade the Ops people that it’s worth doing for this one time.

              If, as I suspect, however, I’m going to find more and more occasions when it would be useful, that could definitely change!

              I’ll keep you posted! (does that qualify as a pun?!) grin

              Many thanks for your help, again!!

            • #665711

              In fact, I just notice that although the page loads fine, as soon as I click on the javascript link it says ‘Errors on page’ at the bottom … I must be doing something wrong somewhere!

              In the meantime, it opened Word but nothing in it …

              sigh

            • #665482

              Jefferson

              Thanks for the slick demo code. Its amazing that it takes so little code to call a browse for file dialog.

              Do you happen to know the syntax to return as a variable the name of the path where the html file is located? Clicking the browse button uses some other collective memory item to point at a recent path from ‘who knows what’ program.

              My grand plan is to include in the script the current path and concatenate the filename.doc as the files I would call via a hyperlink would be stored relative to that path.

            • #665557

              IE seems to remember the last Browse… (see File>Open…) and Save As paths separately, but I have never tried to figure out how to access this information. Possibly it’s in the registry, which presents severe problems for a lowly script; possibly there’s a JavaScript trick to get at it. Nothing comes readily to mind…

    Viewing 1 reply thread
    Reply To: Open documents and start macros in doc. (IE 6.0.2600.000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: