Open a MS Word document from InTouch and go to a specific bookmark.

Ø

Thread Starter

Øyvind Haugland

I would like to open a MS Word document from InTouch and go straight to a specific bookmark in this document. Has anyone done this?

Øyvind Haugland
 
You can try 2 Wonderware script functions startapp to open word and a specific doc then have wwexecute call a macro in word that goes to a specific bookmark.
 
T
No, and I don't know how you would. Perhaps a VBA macro in word might do it. You might try converting the file to HTML and opening it with a browser from InTouch. Most HTML books cover how to do this.
 
Create a button with an action link using the "Startapp" command. See your Help files for detailed description.

It would be something like;

Startapp "path1/winword.exe path2/filename.doc";

Note that the 'path1/' part must be the path to winword and 'path2/' must be the path to the file.
The path must not have any spaces in it as Winword doesn't seem to like this.

This will get Winword running with your file open (if your file exists). If it doesn't exist, it will at least get winword open. As for getting to a bookmark in the file, you're on your own.

Be careful to password protect this link as it is very easy for a reasonably smart guy to get to the internet through winword. This would open your system to all sorts of porn (and/or viruses if you have no firewall but have ADSL or cable
connection to the internet).

Good luck,
 
M

Morten Johansen

Øyvind,

Try to use
(From InTouch)
*WWStartApp to launch winword
*WWExecute to launch your Word Macro

(From Word)
*A Macro

You should make a tag which hold your bookmark value. This tag can you put in in a cell in the document. This cell read the value of your tag = the macro can read it.

The macro is moving you around in the document based on your bookmark value given from InTouch.

Morten Johansen
www.aventi.no
 
Ø

Øyvind Haugland

> You can try 2 Wonderware script functions startapp to open word and a specific doc
> then have wwexecute call a macro in word that goes to a specific bookmark.

Thanks for all the answers. Here is how far I've come (still not able to run the macro in word, but I'm close to it):

This is a script that runs the macro "Makrotest" in Excel (Macro and Command are defined as MemoryMessagetag, Excel is already running in the background with the sheet "DDE_Test"):

Macro = "DDE_Test.xls!Makrotest";
Command = "[Run(" + StringChar(34) + Macro + StringChar(34) + ")]";
WWExecute( "excel", "system", Command );

It works! But let's make an equal script for running script in Word:

Macro = "Bookmark";
Command = "[Run(" + StringChar(34) + Macro + StringChar(34) + ")]";
WWExecute( "winword", "system", Command );

This doesn't work! I get the errormessage "Compile error: Sub or Function not
defined" in VB, and the macro "TmpDDE" were tried started (although I have made a macro in Word called "Bookmark" and run OK in Word).

I looked at the MS Webpage
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q177760. There it says how to run macros in other programs:
Excel: XL.Run "TestMacro"
Word: WD.Run "Project.Module1.WordMacro"

I tried to put in projectname and modulename in addition to the macroname, as this page says, but I wasn't able to run it without errors.

Does anyone have experience with/suggestions to how to solve this?
 
Try Creating a macro that runs when you open the WORD document. Example (The name of the bookmark is "scope")::

Sub AutoOpen()
'
' Auto_Open Macro
' Macro created 6/7/02
'
Selection.GoTo What:=wdGoToBookmark, Name:="Scope"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End Sub
 
Top