Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: Creating hyperlinks in a Word doc with VBS

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,57166
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Creating hyperlinks in a Word doc with VBS
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2]
Login
Message << Older Topic   Newer Topic >>
 RE: Creating hyperlinks in a Word doc with VBS - 3/20/2008 3:01:23 AM   
  Thorsteenster

 

Posts: 18
Score: 0
Joined: 2/27/2008
Status: offline
Also tried this:
ActiveDocument.Hyperlinks.Add Anchor = ObjSelection.Range, Address = "http://kaboom.org", SubAddress = "", ScreenTip = "", TextToDisplay = "http://kaboom.org"
Which gives me:
Error: Object required: 'ActiveDocument'
Code: 800A01A8

(in reply to Thorsteenster)
 
 
Post #: 21
 
 RE: Creating hyperlinks in a Word doc with VBS - 3/20/2008 3:04:18 AM   
  Thorsteenster

 

Posts: 18
Score: 0
Joined: 2/27/2008
Status: offline
quote:

ORIGINAL: ebgreen

Try this:


ActiveDocument.Hyperlinks.Add(ObjSelection.Range, "http://kaboom.org",,, "http://kaboom.org")


That gave me Cannot use parentheses when calling a Sub, Code: 800A0414

(in reply to ebgreen)
 
 
Post #: 22
 
 RE: Creating hyperlinks in a Word doc with VBS - 3/20/2008 3:16:07 AM   
  ehvbs

 

Posts: 2173
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Thorsteenster,

(1) you can't use named arguments to a Sub, Function, or Method in VBScript (in VBA it's
     possible); so

         ActiveDocument.Hyperlinks.Add Anchor = ObjSelection.Range, ...

     isn't legal VBScript. To convert VBA macro code to VBScript you'll have to replace the
     named arguments by a (correct!) sequence of positional parameters.

        ActiveDocument.Hyperlinks.Add <FrsParam>, ...

     To obtain the correct sequence, check the documentation

(2) It's illegal in VBScript to use parameter list () when calling a Sub (or a Function or
     Method as a Sub, i.e. without assigning the return value to a variable); so

       ActiveDocument.Hyperlinks.Add(ObjSelection.Range, "http://kaboom.org",,, "http://kaboom.org")

   
is bad VBScript.

So clean up your "ActiveDocument.Hyperlinks.Add" call.

Good luck!

ehvbs

(in reply to Thorsteenster)
 
 
Post #: 23
 
 RE: Creating hyperlinks in a Word doc with VBS - 3/20/2008 3:21:10 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
yup, my bad on the parens. I didn't look it up to see if the method was treated as a sub or a function.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ehvbs)
 
 
Post #: 24
 
 RE: Creating hyperlinks in a Word doc with VBS - 3/20/2008 3:29:16 AM   
  Thorsteenster

 

Posts: 18
Score: 0
Joined: 2/27/2008
Status: offline
Sorry, how do I clean up a call? The call is what I got from the macro I created to see the language for creating a link.

(in reply to ebgreen)
 
 
Post #: 25
 
 RE: Creating hyperlinks in a Word doc with VBS - 3/20/2008 3:31:37 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
In this case to clean it up you should just be able to take what I posted and get rid of the parens.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Thorsteenster)
 
 
Post #: 26
 
 RE: Creating hyperlinks in a Word doc with VBS - 3/20/2008 3:48:07 AM   
  Thorsteenster

 

Posts: 18
Score: 0
Joined: 2/27/2008
Status: offline
Still says Object required. Something I found on Google says ActiveDocument is a property of Word and needs to be proceeded with something, so I tried ObjSelection.ActiveDocument.Hyperlinks.Add, but that was not supported.

(in reply to ebgreen)
 
 
Post #: 27
 
 RE: Creating hyperlinks in a Word doc with VBS - 3/20/2008 3:54:43 AM   
  ehvbs

 

Posts: 2173
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Try "objDoc" instead of "ActiveDocument".

(in reply to Thorsteenster)
 
 
Post #: 28
 
 RE: Creating hyperlinks in a Word doc with VBS - 3/20/2008 4:22:22 AM   
  Thorsteenster

 

Posts: 18
Score: 0
Joined: 2/27/2008
Status: offline
Ding ding ding, we have a winner!!
ObjDoc.Hyperlinks.Add ObjSelection.Range, "http://projects.kaboom.org/",,, "http://projects.kaboom.org/"
Did the trick, thanks guys!!

(in reply to ehvbs)
 
 
Post #: 29
 
 
Page:  <<   < prev  1 [2]
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Creating hyperlinks in a Word doc with VBS Page: <<   < prev  1 [2]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts