|
-
Feb 10th, 2012, 11:01 AM
#1
Thread Starter
Hyperactive Member
[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
-
Feb 11th, 2012, 04:01 AM
#2
Re: Follow Hyperlink Help
what application are you writing your code in?
followhyperlink is not a valid function in my version of office
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 11th, 2012, 08:18 AM
#3
Thread Starter
Hyperactive Member
Re: Follow Hyperlink Help
I am using this code in Excel 2000.
-
Feb 11th, 2012, 10:14 PM
#4
Re: Follow Hyperlink Help
in excel 2000, i have no followhyperlink function, only a worksheet event of that name
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 11th, 2012, 11:32 PM
#5
Thread Starter
Hyperactive Member
Re: Follow Hyperlink Help
 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?
-
Feb 12th, 2012, 03:15 AM
#6
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 12th, 2012, 12:25 PM
#7
Thread Starter
Hyperactive Member
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.
-
Feb 12th, 2012, 02:57 PM
#8
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|