Microsoft Word - Word macro can access outer application with params throught hyperlink

Asked By József Keller
03-Feb-12 09:44 AM
Hi,

I am using Word 2000.

I develop a new application under MS Word with macros. Word provides the ability of text edition (using Word is compulsory) and each paragraph of the text has a hyperlink to call an outer application to play the wave file belongs to that text. My problem is that some parameters should be given to that outer application (the name of the .wav file the starting and ending timestamps of the .wav file that are in connection with the text paragraph to be examined). How can I give parameters through a file:/// protocol? The hyperlinks can use this protocol to access the outer application. Word MACROS are able to access outer applications (NOTEPAD.EXE), but parameters cannot be given (for example in case of notepad.exe <text_filename>, the notepad.exe will be started without opening the given existing file).

If you had a good idea, it would be appreciated. Thanks for your help.

 Best regards,
Jozsef Keller

  Danasegarane Arunachalam replied to József Keller
03-Feb-12 09:56 PM
From here I can see that the Hyperlink does not support the file name with parameters method. And you could do a work around with the macro button

1. Open the VBA Editor by pressing the ALT+F11 Button
2. Create a small sub to open the macro

Sub OpenNotepad()
  Shell ("notepad.exe C:\Temp.txt")
End Sub
 
'This Tell the winword that open the macro in single button click
Private Sub Document_New()
   Application.Options.ButtonFieldClicks = 1
End Sub

3. Close the VBA Editor
4. And in the Document window Press Ctrl+F9
5. This will place the Macro button tag in the document as
{}


6. Now type the text as



           Where
              MacroButton is the keyword to place the macro button
             OpenNotepad is the MacroName
             Open notepad is the Display Text

7. Now Right Click the Inserted button and select the Toggle field option
8. Now you will see "Click Here to Open NotePad" option
9.Press Ctrl+Shift+S option and from the style select the HyperLink



10. Now you link, Press the button. This will open the Notepad
11. I have use the Shell Function of Word VBA to open External Application


Sample file




  Danasegarane Arunachalam replied to József Keller
03-Feb-12 09:57 PM
Sample missed in previous post.


And here it is

Hyperlinks.zip
  Anoop S replied to József Keller
04-Feb-12 04:10 AM
Refer this example for Opening specified file, and append input to textfile

Sub PrintToTextFile()

Dim FileNum As Integer, cl As Range, z As Integer, y As Integer
Dim myStr As String
FileNum = FreeFile ' next free filenumber
Open "C:\temp\TEXTFILE.TXT" For Append As #FileNum
Print #FileNum, [a1]
z = 10
For Each cl In [b10:f30]
    y = cl.Row
    If y = z Then
      myStr = myStr & "|" & cl
     
'appends the input to an existing file write to the textfile
    Else: Print #FileNum, myStr
      z = cl.Row
      myStr = "": myStr = myStr & "|" & cl
    End If
Next

'appends the input to an existing file write to the textfile

Print #FileNum, myStr
Close #FileNum ' close the file

End Sub
  József Keller replied to Danasegarane Arunachalam
06-Feb-12 06:56 AM
Hi,

Thanks for your help. It works.

Best regards,
József Keller
  József Keller replied to Anoop S
06-Feb-12 07:01 AM
Hi,

My problem was not the same, but this code is useful for me. Thanks.

Best regards,
József Keller
Create New Account
help
Error! Hyperlink reference not valid. Word Microsoft Word suddenly started replacing all the hyperlinks in my documents with this phrase, "Error! Hyperlink reference not valid. " Actually, it's not each link.) This is a very disruptive problem for me since I often download lengthy word documents that have hundreds of links in them. It does the same if I manually change the text to a link. I'm using Microsoft Word 2003 SP3. Please help Word Application Errors Discussions Microsoft Word (1) Barnhill (1) Fairhope (1) Alabama (1) Alt (1) Hundreds
Word & hyperlinks Word I have inserted hyperlinks into a Word document. When I send an e-mail with the Word doc attached, the recipient cannot open the links. Any help? Thanks. Word Document Management Discussions Microsoft Word (1) Word (1) Stefan Blom (1) Word hyperlinks (1) Word document (1) Hyperlinks (1
Read Write Hyperlinks Microsoft.Office.Interop.Word .NET Framework Trying to read the hyperlink(s) from Word 2007 documents, make changes and write them back. Being new to C#, I am not sure how to address the Microsoft.Office.Interop.Word.Hyperlinks collection correctly. Thanx in adavnce, Greg C# Discussions Microsoft.Office.Interop.Word.Hyperlinks (1) Word.WdAlertLevel.wdAlertsNone (1) Microsoft Word (1) WaitForPendingFinalizers (1) Office
Stripping hyperlinks Word Word 2007 inexplicably started stripping all hyperlinks, email addresses and other automated information a few months ago, and I cannot find anything an example, a link such as www.yahoo.com will appear as {HPERLINK Please help!! Word Document Management Discussions Microsoft Word (1) Word 2007 (1) BlomMicrosoft (1) Alt (1) HPERLINK (1) Months (1) Press Alt+F9 to hide
Hyperlinks in Microsoft Word 2003 show the "hidden" information when printed Word Hi, After adding hyperlinks into a Microsoft Word 2003 document and printing it (on paper or as a PDF document), the hyperlinks appear like this: {HYPERLINK "http: / / .www.xxxx. . . . "} page numbers look like this: {PAGE} email links