Sie sind vermutlich noch nicht im Forum angemeldet - Klicken Sie hier um sich kostenlos anzumelden Impressum 
Sie können sich hier anmelden
Dieses Thema hat 12 Antworten
und wurde 161 mal aufgerufen
 Skripte und Zusatzprogramme
monkey8 Offline



Beiträge: 315

21.05.2011 12:14
RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Here are some scripts that will open hyperlinks directly in Microsoft Word, the first script will open all the hyperlinks on a particular page in different tabs on one instance of Internet Explorer. The second script will open individual hyperlinks e.g. "open hyperlink 2" You need to set references to the Microsoft Word object library and Microsoft Internet Controls 1,1. I would be grateful if one of my fellow moderators could test with the German version of DNS and/or convert the scripts accordingly.

(Name the script something like "open all hyperlinks").

1.

'Script by Lindsay Adam, PCByVoice www.pcbyvoice.com
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim doc As Document
Dim ie As InternetExplorer
Dim i
Sub Main
Set ie = New InternetExplorer
For Each doc In Application.Documents
For i = 1 To doc.Hyperlinks.Count
webpage = doc.Hyperlinks (i).Address
ie.Visible = True
If i = 1 Then ie.Navigate webpage
If i > 1 Then ie.Navigate webpage, 1
Next
Next
SetForegroundWindow ie.HWND
End Sub

The next script will open individual hyperlinks as in the following examples:

2.

"open hyperlink 1"
"open hyperlink 3"

Again remember to set the references.

'Script by Lindsay Adam, PCByVoice www.pcbyvoice.com
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Sub Main
Dim doc As Document
Dim ie As InternetExplorer
For Each doc In Application.Documents
For i = 1 To doc.Hyperlinks.Count
If i = ListVar1 Then
Set ie = New InternetExplorer
webpage = doc.Hyperlinks (i).Address
ie.Visible = True
ie.Navigate webpage
End If
Next
Next
SetForegroundWindow ie.HWND
End Sub

I have also attached the commands in an XML file so you can import directly into the Command Browser. The command names are:

"open all hyperlinks"
"open hyperlink " e.g. "open hyperlink 4"

Lindsay
www.pcbyvoice.com

Dateianlage:
Aufgrund eingeschränkter Benutzerrechte werden nur die Namen der Dateianhänge angezeigt Jetzt anmelden!
f12t579p4127n104.xml
Marius Raabe Offline



Beiträge: 718

21.05.2011 13:28
#2 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Lindsay,
good to read from you and thanks. They both work like the proverbial charm, I copy-and-pasted them and tested them under Office 2007. The only issue was that the first one did not open the links in tabs in the same windows, but in different windows of IE9, but that may be due to some settings of my version.

Cheers, Marius

Dragon NaturallySpeaking 11.5 Legal
Windows 7 Prof. 64-Bit, Office 2010, Jarte Plus
Philips SpeechMike II Pro Plus, SpeechMike III, SpeechMike Air, PDCC 2.8
Intel Core2 Quad Q9550, 2,83 GHz, 2x6MB L-2, 8 GB RAM

Dateianlage:
Aufgrund eingeschränkter Benutzerrechte werden nur die Namen der Dateianhänge angezeigt Jetzt anmelden!
f12t579p4128n106.xml
monkey8 Offline



Beiträge: 315

21.05.2011 14:23
#3 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Thank you Marius and good to hear from you as always. Try changing the navigate lines of the script to open all the hyperlinks to the following:

If i = 1 Then ie.Navigate2 webpage
If i > 1 Then ie.Navigate2 webpage, 2048

note that the method is now called Navigate2 and not Navigate.

Lindsay

Marius Raabe Offline



Beiträge: 718

21.05.2011 15:20
#4 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Perfetto!
Now everyone is waiting for something to do something comparable in Outlook-Mails in reading mode ...

Michael Schumacher

Dragon NaturallySpeaking 11.5 Legal
Windows 7 Prof. 64-Bit, Office 2010, Jarte Plus
Philips SpeechMike II Pro Plus, SpeechMike III, SpeechMike Air, PDCC 2.8
Intel Core2 Quad Q9550, 2,83 GHz, 2x6MB L-2, 8 GB RAM

Dateianlage:
Aufgrund eingeschränkter Benutzerrechte werden nur die Namen der Dateianhänge angezeigt Jetzt anmelden!
f12t579p4130n107.xml
JoeBu Offline




Beiträge: 213

21.05.2011 15:37
#5 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Hello Lindsay, hello Marius,

thanks a lot for the script and the translation. I would like to use the similar script for hyperlinks in Microsoft Excel. Which lines of the code I need to change and why?
I really would like to understand your kind of programming in DNS.

Regards

Jörg

monkey8 Offline



Beiträge: 315

22.05.2011 11:11
#6 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Hello Jörg

unfortunately all the Microsoft applications have their own individual APIs (application programming Interface) and they are all unique in their own right. Basically there is no fixed pattern between them where you can simply change a couple of commands to get a Microsoft Word macro working in Microsoft Excel.

I am not too familiar with the Microsoft Excel API so without investigating thoroughly I don't know the easy way to open hyperlinks in an Excel document although I am sure it can be done.

If you want to be able to do such things in terms of programming/scripting then the best place to start is with "Larry Allen’s scripting guide" which is available as a paper copy or a PDF copy. We sell either from our website but the shop will not be active until the first of June, if you want to purchase the scripting guide in the meantime then let me know and I can sort it out for you. Larry fixes the prices at exactly the equivalent of US$49, if you buy the paper copy then obviously there will be postage on top of that. Alternatively you can get the scripting guide from various places in America (sorry I don't know if it's available in Germany).

It takes time and lots of patience to learn to program/script to any significant level but the sooner you start the better.

Best wishes
Lindsay
www.pcbyvoice.com

R.Wilke Offline



Beiträge: 6.357

22.05.2011 12:33
#7 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Hello Jörg and everyone,

What is being involved here is the so-called VBA (Visual Basic for applications) which comes for Microsoft products such as Word, Excel, Outlook, Internet Explorer etc. As such and being based on Visual Basic, actually being extensions to Visual Basic for each given application, being familiar with the main elements and concepts in Visual Basic certainly will help, but there are a lot of places and ways to start from so it does not really take having been a full-time programmer for years in order to do a few scripts in it. And I would like to show you how and where to start.

To begin with, I would seriously suggest not starting doing VBA scripts from within Advanced Scripting in Dragon NaturallySpeaking, although it is perfectly accommodated to it, but just because it does not really improve your overall understanding of it due to not being the place it has been designed in.

With every of the Microsoft products named above, there is a built in Visual Basic editor which will give you all the functionality you will need to actually test and develop your own scripts, and you will best be off by starting with prefabricated samples which you will find loads of all over the Internet when doing the appropriate searches for it. Therefore, if you are interested in doing something in Microsoft Word, just do a search for "VBA for Word", along with an appropriate keyword according to what you are planning to do. First become a little familiar with using the Visual Basic editor, which should not take longer than 30 min. actually if you do one of the many tutorials you will find.

The most important thing about VBA to understand however is that it incorporates a particular so-called object model for each application which is how the interfaces provided by it are implemented, along with all the rest, what is being referred to as "members", functions, properties, etc. This simply means that if the particular object model provides what you are looking for, it can be done, but it cannot be done if it does not. In addition to that, each object model has a hierarchical structure with all the elements being structured from top to bottom, with branches in various directions, and I am just pointing this out to you to make you aware of that if what you are trying to do does not work from the start it may just be because what you think going from A to B means is more like going from A to C.

One of the implications of being object models however also is that, whenever you create and initiate an object instance, you will also have to take care of dereferencing or deleting it properly, most likely at the end of the code. Therefore, when doing something like

Set ie = New InternetExplorer

Do not forget to do the following at the end of the code

Set ie = Nothing

Sorry Lindsay for having to bring this up, but that is one flaw with the code that you have provided if you ask me, although it will certainly and obviously run – at least for some time. I know it has been your Alzheimer's kicking in.

Finally, since Lindsay also mentioned it, Larry Allen's book of course is one of the most important sources of information as regards Advanced Scripting, and it also contains quite a few things dealing with VBA although this is not what I would buy it for.

And yes, you can get the English version also here in Germany, although places are not easy to find and you will have to pay considerably more than if you were buying in the US or the UK obviously, and also there has been a German translation around for quite a few years which has been provided by Herman Meltzer, one of the members of this forum who used to come posting here before he was made to change his mind and stop doing so.

Have a nice Sunday everyone
Rüdiger

_______________________________________

Dragon Professional 16 auf Windows 10 Pro und Windows 11
SpeechMike Premium (LFH3500); Office 2019 Pro + Office 365 (monatliches Abo)
HP ZBook Fury 17 G8 - i7-11800H - 24 MB SmartCache - 32 GB RAM - 1 TB SSD

monkey8 Offline



Beiträge: 315

22.05.2011 13:12
#8 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Rüdiger

Of course you should always tidy up your objects and incorporate proper error handling and I always do in my normal programming environment, however this involves additional resources and time for just about any script. Considering I am in possession of your performance application source code and have seen many of your scripts in the past you need to practice what you preach you can't just pick on one particular object and say that I haven't dereferenced it, dispose of it properly because there are numerous examples on this forum with the same issue, no unregistering of Dragon objects, no disposing of Dragon objects and the same issue with other Microsoft Outlook objects etc.

Best wishes
Lindsay

R.Wilke Offline



Beiträge: 6.357

22.05.2011 13:24
#9 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Lindsay, no argument over it intended, between you and me, which I wouldn't be in a position to do anyway, being an amateur in the true sense of the word.

Have a nice Sunday
Rüdiger

_______________________________________

Dragon Professional 16 auf Windows 10 Pro und Windows 11
SpeechMike Premium (LFH3500); Office 2019 Pro + Office 365 (monatliches Abo)
HP ZBook Fury 17 G8 - i7-11800H - 24 MB SmartCache - 32 GB RAM - 1 TB SSD

monkey8 Offline



Beiträge: 315

22.05.2011 14:02
#10 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Rüdiger

I don't think we are arguing anyway because you make a very good point, we should all be dereferencing and disposing of objects in the correct manner, in some instances of programming like with the CLR (.NET) some of this is done automatically but not always with the basic scripting engine WinWrap Basic that DNS uses. I think even more important is error handling and very rarely is this provided with scripts on this or any other forums. If I am working in my normal programming environment then I always make sure I incorporate both tidying of objects and error handling, and as you know this is extremely time-consuming and not exactly the most fun part of programming.

Incidentally being lucky enough to be a recipient of some of your current programming investigations with SAPI 4 (I shall say no more than that) I would hardly call you an amateur, as you know I am continually amazed by your progress and you are way ahead of me there.

Lindsay

R.Wilke Offline



Beiträge: 6.357

22.05.2011 14:51
#11 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Thanks for the flattering, oh sorry I meant to say "encouragement". If you are willing to consider someone very often playing by intuition like the deaf dumb and blind kid not being an amateur, and wasting hours to days with the usual trial and error procedures an appropriate way of spending your time, then I am not an amateur.

I just thought that it is worth pointing out that minimally error-checking and taking care of object instances might be a consideration even with the simple scripts. At least I found out the hard way that when the scripts do not work like you would expect them to, this could be it.

Rüdiger

_______________________________________

Dragon Professional 16 auf Windows 10 Pro und Windows 11
SpeechMike Premium (LFH3500); Office 2019 Pro + Office 365 (monatliches Abo)
HP ZBook Fury 17 G8 - i7-11800H - 24 MB SmartCache - 32 GB RAM - 1 TB SSD

monkey8 Offline



Beiträge: 315

27.05.2011 13:56
#12 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Just an update on opening hyperlinks in Microsoft Office documents. The following commands all work on just the current instance of Word and not on all Word documents. I expect you can do a similar thing for XL (you will need to do your homework), you just need to assign the active document to the variable doc.Also includes disposing of objects and a modicum of error handling especially for Rüdiger. The script is identical except for the items highlighted in bold. The scripts will additionally differentiate between e-mail hyperlinks and URL hyperlinks.

Lindsay
www.pcbyvoice.com

Command Name: OPEN Hyperlink (application specific to Outlook)

'Script by Lindsay Adam, PCByVoice www.pcbyvoice.com
'Set References to Microsoft Object Library for Outlook and Microsoft Internet Controls
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As _
Long, ByVal nCmdShow As Long) As Long
Sub Main
Set doc = Application.ActiveInspector.WordEditor
Index = Val (ListVar1)
If Index (application specific to Word)[/b]

'Script by Lindsay Adam, PCByVoice www.pcbyvoice.com
'Set References to Microsoft Object Library for Word and Microsoft Internet Controls
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As _
Long, ByVal nCmdShow As Long) As Long
Sub Main
Set doc = ActiveDocument
Index = Val (ListVar1)
If Index <= doc.Hyperlinks.Count Then
webpage = doc.Hyperlinks (Index).Address
Dim ie As New InternetExplorer
ie.Navigate webpage
If Not Mid (webpage, 1, 7) = "mailto:" Then
ie.Visible
ShowWindow ie.HWND, 9
SetForegroundWindow ie.HWND
End If
Set ie = Nothing
Set doc = Nothing
Else
MsgBoxConfirm "No such hyperlink",0,"Error opening Hyperlink"
End If
End Sub

Marius Raabe Offline



Beiträge: 718

27.05.2011 16:45
#13 RE: Opening hyperlinks in a Microsoft Word document by voice Zitat · Antworten

Lindsay,

thanks again for your tireless efforts and kudos for another impressing show of force!

Works perfectly.

Marius

Dragon NaturallySpeaking 11.5 Legal
Windows 7 Prof. 64-Bit, Office 2010, Jarte Plus
Philips SpeechMike II Pro Plus, SpeechMike III, SpeechMike Air, PDCC 2.8
Intel Core2 Quad Q9550, 2,83 GHz, 2x6MB L-2, 8 GB RAM

Ähnliche Themen Antworten/Neu Letzter Beitrag⁄Zugriffe
Ich kann nicht mehr in Word diktieren.
Erstellt im Forum Fragen zur Anwendung von rc.otto
1 03.05.2023 08:36
von rc.otto • Zugriffe: 522
Wie unter Dragon 16 und MS 365 Skriptbefehle mit Word-VBA-Makros?
Erstellt im Forum Skripte und Zusatzprogramme von Marius_
4 14.03.2023 11:33
von Marius_ • Zugriffe: 416
Open Office oder Word
Erstellt im Forum Fragen zur Anwendung von Tommy
2 30.08.2022 22:04
von R.Wilke • Zugriffe: 264
Kommentarfunktion in Word: Dragon funktioniert nicht mehr
Erstellt im Forum Fragen zur Anwendung von rc.otto
2 12.08.2022 12:22
von Marius_ • Zugriffe: 325
Formatierung in Word 2019
Erstellt im Forum Fragen zur Anwendung von Gilby2000
1 22.01.2022 15:41
von Marius_ • Zugriffe: 328
Smileys bei Microsoft Word führen zum Absturz von Dragon
Erstellt im Forum Fragen zur Anwendung von Lena
3 29.01.2022 14:39
von Lena • Zugriffe: 420
DRA-Datei in WORD erstellen/speichern
Erstellt im Forum Fragen zur Anwendung von spk347
3 14.04.2021 19:08
von spk347 • Zugriffe: 1115
Diktieren in Open Office
Erstellt im Forum Fragen zur Anwendung von wulf.greiner
1 11.03.2021 09:45
von P.Roch • Zugriffe: 1272
DPI/DPG aktuelle Versionen: Microsoft 365, speziell Word im Browser/Microsoft Teams/RDS Farm
Erstellt im Forum Fragen zur Anwendung von Udo Weik
1 08.02.2021 12:33
von Marius_ • Zugriffe: 681
Microsoft Word per Sprachbefehl starten
Erstellt im Forum Fragen zur Anwendung von STAHL
5 07.04.2021 11:25
von STAHL • Zugriffe: 555
 Sprung  
Xobor Ein Kostenloses Forum | Einfach ein Forum erstellen
Datenschutz