dhancy
Board Regular
- Joined
- Jul 10, 2013
- Messages
- 123
- Office Version
- 365
- Platform
- Windows
My Excel VBA creates a Word Document.
I want to add a hyperlink to some of the text in this document.
Here is a snippet of the code:
The ".hyperlinks" line I obtained from recording a macro in Word.
When I attempt to run this, I get the error:
--
Run-time error '450':
Wrong number of arguments or invalid property assignment
---
In my debugging efforts, I noticed this: When I type out ".hyperlinks.add ", I see the pop up list of help tips to complete the command. There are six properties shown: Anchor, Address, SubAddress, ScreenType, TextToDispay AND Target.
I am guessing the error means there is another argurment I need to pass - Target. What is that? What value to I use for it? And how come that doesn't show up when I recorded the Word macro?
Thanks,
Dennis
I want to add a hyperlink to some of the text in this document.
Here is a snippet of the code:
Code:
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add(Template:=folder & "\DD3.dotx")
...
With wrdApp.Selection
.TypeParagraph
.TypeText sometext
.Hyperlinks.Add Anchor:=Selection.Range, Address:=file & ".pdf", _
SubAddress:="", ScreenTip:="", TextToDisplay:=file
...
end with
The ".hyperlinks" line I obtained from recording a macro in Word.
When I attempt to run this, I get the error:
--
Run-time error '450':
Wrong number of arguments or invalid property assignment
---
In my debugging efforts, I noticed this: When I type out ".hyperlinks.add ", I see the pop up list of help tips to complete the command. There are six properties shown: Anchor, Address, SubAddress, ScreenType, TextToDispay AND Target.
I am guessing the error means there is another argurment I need to pass - Target. What is that? What value to I use for it? And how come that doesn't show up when I recorded the Word macro?
Thanks,
Dennis