[RESOLVED] Follow Hyperlink Help
I am running the below code which will open a folder based upon what the user enters into a text box.
Code:
varProgram = UserForm1.Text
Set wordapp = CreateObject("word.Application")
wordapp.Documents.Open "C:\Main\" & varWord & "_New.doc"
wordapp.Visible = True
strFolder = "C:\Main\" & varWord & "_New\\"
FollowHyperlink Address:=strFolder, NewWindow:=True
This works fine if I am just going to run it once. If I try to run the code a second time, I get permission denied? Can someone help me understand why it works perfect once, but not a 2nd time? The line that is highlighted as causing the error is this one:
Code:
FollowHyperlink Address:=strFolder, NewWindow:=True
Re: Follow Hyperlink Help
what application are you writing your code in?
followhyperlink is not a valid function in my version of office
Re: Follow Hyperlink Help
I am using this code in Excel 2000.
Re: Follow Hyperlink Help
in excel 2000, i have no followhyperlink function, only a worksheet event of that name
Re: Follow Hyperlink Help
Quote:
Originally Posted by
westconn1
in excel 2000, i have no followhyperlink function, only a worksheet event of that name
It's not a function that I was using. It was simple just followhyperlink and then type the address that you want to follow. There are several different forums that I have seen this example on, this is the 1st one that came up when I googled:
http://www.vbaexpress.com/forum/arch...php/t-536.html
Can you provide a different example of how to accomplish the same feat as I am needing?
Re: Follow Hyperlink Help
on checking, followhyperlink is method of a document object, so should be
thisdocument.followhyperlink
activedocument.followhyperlink or in your case
wrdapp.documents(1).followhyperlink
this is a common problem when automating applications, when objects are not fully qualified, work once but will not repeat
Re: Follow Hyperlink Help
I'll test that out. I am using it on an Excel Userform, and I want to open the folder that is typed into the textbox on the Userform. It opens fine, the 1st time, but errors the 2nd. I'll have to test these out, and see if using any of the other ones will remove the issue.
Re: Follow Hyperlink Help
as you are doing your code in excel, you can use the followhyperlink method of any workbook object, rather than the wrdapp document object, i doubt it will make any difference