| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools | Rate Thread |
|
|
|
| |
|
Douglas J. Steele
Guest
Posts: n/a
|
If you can strip the full path out of the hyperlink, you can use
If Len(Dir(FullPath)) = 0 Then ' file doesn't exist Else ' file exists End If Far faster than opening each instance. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "4110" <(E-Mail Removed)> wrote in message news:969B61A9-8C87-4DC0-ACD2-(E-Mail Removed)... >I have a database to manage documents. The database record for each >document > includes a hyperlink to the document. WIth the normal changes that occur > over time, some of the links are no longer correct. I would to create a > small application that loops through all the records, tests the hyperlinks > and records the invalid links. I know how to follow a hyperlink in code > to > open the document. If the link is good then I will end up with an open > document. How do I close that document from code? > > Thanks, > > David |
|
||
|
||||
|
|
|
| |
|
=?Utf-8?B?NDExMA==?=
Guest
Posts: n/a
|
Thank you for your excellent suggestion. I do store a path as well as the
hyperlink in the database. At first I thougt your suggestion opened up a new, and perhaps more important test than hyperlink validity, namely does the document exist and agree with the name/path in the database. Unfortunately, the documents are on a company ePortal rather than a hard drive and I can't type the path into Windows Explorer and get anywhere. To get to a document I have to open Internet Explorer, go to the ePortal and then click through the folders to navigate to a document. The path that I store in the database cooresponds to the folder heirarchy on the way to a document. I can also click on the stored hyperlink and open the document directly. The hyperlinks start out: https://eportal.companyname... They don't seem to have the path embedded in them. In summary, I don't know how to make your idea work. Also, even if we can use your test to verify the existance and location of the document, a hyperlink validity test would still be useful. Thank again, David "Douglas J. Steele" wrote: > If you can strip the full path out of the hyperlink, you can use > > If Len(Dir(FullPath)) = 0 Then > ' file doesn't exist > Else > ' file exists > End If > > Far faster than opening each instance. > > -- > Doug Steele, Microsoft Access MVP > http://I.Am/DougSteele > (no e-mails, please!) > > > "4110" <(E-Mail Removed)> wrote in message > news:969B61A9-8C87-4DC0-ACD2-(E-Mail Removed)... > >I have a database to manage documents. The database record for each > >document > > includes a hyperlink to the document. WIth the normal changes that occur > > over time, some of the links are no longer correct. I would to create a > > small application that loops through all the records, tests the hyperlinks > > and records the invalid links. I know how to follow a hyperlink in code > > to > > open the document. If the link is good then I will end up with an open > > document. How do I close that document from code? > > > > Thanks, > > > > David > > > |
|
||
|
||||
|
Douglas J. Steele
Guest
Posts: n/a
|
Well, it'll be very slow, but you should be able to use the GetObject
function to retrieve a reference to the open document. For example, assuming you're dealing with a Word document, you should be able to do something like: Dim objWord As Object Dim objDocument As Object Dim intLoop As Integer Set objWord = GetObject(, "Word.Application") For intLoop = (objWord.Documents.Count - 1) To 0 Step -1 Set objDocument = objWord.Documents(intLoop) objDocument.Close SaveChanges:=0 ' don't save changes Next intLoop objWord.Application.Quit Set objWord = Nothing -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "4110" <(E-Mail Removed)> wrote in message news:4F8A75AE-B1BA-48DD-A40D-(E-Mail Removed)... > Thank you for your excellent suggestion. I do store a path as well as the > hyperlink in the database. At first I thougt your suggestion opened up a > new, and perhaps more important test than hyperlink validity, namely does > the > document exist and agree with the name/path in the database. > > Unfortunately, the documents are on a company ePortal rather than a hard > drive and I can't type the path into Windows Explorer and get anywhere. > > To get to a document I have to open Internet Explorer, go to the ePortal > and > then click through the folders to navigate to a document. The path that I > store in the database cooresponds to the folder heirarchy on the way to a > document. I can also click on the stored hyperlink and open the document > directly. > > The hyperlinks start out: https://eportal.companyname... They don't seem > to have the path embedded in them. > > In summary, I don't know how to make your idea work. Also, even if we can > use your test to verify the existance and location of the document, a > hyperlink validity test would still be useful. > > Thank again, > > David > > > "Douglas J. Steele" wrote: > >> If you can strip the full path out of the hyperlink, you can use >> >> If Len(Dir(FullPath)) = 0 Then >> ' file doesn't exist >> Else >> ' file exists >> End If >> >> Far faster than opening each instance. >> >> -- >> Doug Steele, Microsoft Access MVP >> http://I.Am/DougSteele >> (no e-mails, please!) >> >> >> "4110" <(E-Mail Removed)> wrote in message >> news:969B61A9-8C87-4DC0-ACD2-(E-Mail Removed)... >> >I have a database to manage documents. The database record for each >> >document >> > includes a hyperlink to the document. WIth the normal changes that >> > occur >> > over time, some of the links are no longer correct. I would to create >> > a >> > small application that loops through all the records, tests the >> > hyperlinks >> > and records the invalid links. I know how to follow a hyperlink in >> > code >> > to >> > open the document. If the link is good then I will end up with an open >> > document. How do I close that document from code? >> > >> > Thanks, >> > >> > David >> >> >> |
|
||
|
||||
|
=?Utf-8?B?NDExMA==?=
Guest
Posts: n/a
|
Thank you for staying with me. I am getting over my head (code wise) so I am
using your code pretty much as is. What I have right now before your code is: With Me.cmdOpenFile .HyperlinkAddress = txtHyperLink 'set the hyperlink address for the doc .Hyperlink.Follow 'follow the hyperlink to the document .HyperlinkAddress = "" 'reset the hyperlink address End With This code opens the document by following the hyperlink. I put your code behind this and get two errors. If I click the command button to run the code I get error 429 'ActiveX component can't create object'. in line: Set objWord = GetObject(, "Word.Application") I think it is trying to execute this code before the document is open. If I put a stop in this line and wait until the document is open before proceeding then it executes this line OK and but there is another error later in line objDocument.Close SaveChanges:=0 ' don't save changes The error is Run-time error 4605. 'This method or property is not available because the document is in another application.' Is there a fix? Thanks, David "Douglas J. Steele" wrote: > Well, it'll be very slow, but you should be able to use the GetObject > function to retrieve a reference to the open document. For example, assuming > you're dealing with a Word document, you should be able to do something > like: > > Dim objWord As Object > Dim objDocument As Object > Dim intLoop As Integer > > Set objWord = GetObject(, "Word.Application") > > For intLoop = (objWord.Documents.Count - 1) To 0 Step -1 > Set objDocument = objWord.Documents(intLoop) > objDocument.Close SaveChanges:=0 ' don't save changes > Next intLoop > > objWord.Application.Quit > Set objWord = Nothing > > > -- > Doug Steele, Microsoft Access MVP > http://I.Am/DougSteele > (no e-mails, please!) > > > "4110" <(E-Mail Removed)> wrote in message > news:4F8A75AE-B1BA-48DD-A40D-(E-Mail Removed)... > > Thank you for your excellent suggestion. I do store a path as well as the > > hyperlink in the database. At first I thougt your suggestion opened up a > > new, and perhaps more important test than hyperlink validity, namely does > > the > > document exist and agree with the name/path in the database. > > > > Unfortunately, the documents are on a company ePortal rather than a hard > > drive and I can't type the path into Windows Explorer and get anywhere. > > > > To get to a document I have to open Internet Explorer, go to the ePortal > > and > > then click through the folders to navigate to a document. The path that I > > store in the database cooresponds to the folder heirarchy on the way to a > > document. I can also click on the stored hyperlink and open the document > > directly. > > > > The hyperlinks start out: https://eportal.companyname... They don't seem > > to have the path embedded in them. > > > > In summary, I don't know how to make your idea work. Also, even if we can > > use your test to verify the existance and location of the document, a > > hyperlink validity test would still be useful. > > > > Thank again, > > > > David > > > > > > "Douglas J. Steele" wrote: > > > >> If you can strip the full path out of the hyperlink, you can use > >> > >> If Len(Dir(FullPath)) = 0 Then > >> ' file doesn't exist > >> Else > >> ' file exists > >> End If > >> > >> Far faster than opening each instance. > >> > >> -- > >> Doug Steele, Microsoft Access MVP > >> http://I.Am/DougSteele > >> (no e-mails, please!) > >> > >> > >> "4110" <(E-Mail Removed)> wrote in message > >> news:969B61A9-8C87-4DC0-ACD2-(E-Mail Removed)... > >> >I have a database to manage documents. The database record for each > >> >document > >> > includes a hyperlink to the document. WIth the normal changes that > >> > occur > >> > over time, some of the links are no longer correct. I would to create > >> > a > >> > small application that loops through all the records, tests the > >> > hyperlinks > >> > and records the invalid links. I know how to follow a hyperlink in > >> > code > >> > to > >> > open the document. If the link is good then I will end up with an open > >> > document. How do I close that document from code? > >> > > >> > Thanks, > >> > > >> > David > >> > >> > >> > > > |
|
||
|
||||
|
Douglas J. Steele
Guest
Posts: n/a
|
Sorry, no suggestions.
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "4110" <(E-Mail Removed)> wrote in message news:1A68B836-BC7E-46C9-8E75-(E-Mail Removed)... > Thank you for staying with me. I am getting over my head (code wise) so I > am > using your code pretty much as is. What I have right now before your code > is: > > With Me.cmdOpenFile > .HyperlinkAddress = txtHyperLink 'set the hyperlink address > for the doc > .Hyperlink.Follow 'follow the > hyperlink > to the document > .HyperlinkAddress = "" 'reset the hyperlink > address > End With > > This code opens the document by following the hyperlink. I put your code > behind this and get two errors. > > If I click the command button to run the code I get error 429 'ActiveX > component can't create object'. in line: > Set objWord = GetObject(, "Word.Application") > I think it is trying to execute this code before the document is open. > > If I put a stop in this line and wait until the document is open before > proceeding then it executes this line OK and but there is another error > later > in line > objDocument.Close SaveChanges:=0 ' don't save changes > > The error is Run-time error 4605. 'This method or property is not > available > because the document is in another application.' > > Is there a fix? > > Thanks, > > David > > > > > "Douglas J. Steele" wrote: > >> Well, it'll be very slow, but you should be able to use the GetObject >> function to retrieve a reference to the open document. For example, >> assuming >> you're dealing with a Word document, you should be able to do something >> like: >> >> Dim objWord As Object >> Dim objDocument As Object >> Dim intLoop As Integer >> >> Set objWord = GetObject(, "Word.Application") >> >> For intLoop = (objWord.Documents.Count - 1) To 0 Step -1 >> Set objDocument = objWord.Documents(intLoop) >> objDocument.Close SaveChanges:=0 ' don't save changes >> Next intLoop >> >> objWord.Application.Quit >> Set objWord = Nothing >> >> >> -- >> Doug Steele, Microsoft Access MVP >> http://I.Am/DougSteele >> (no e-mails, please!) >> >> >> "4110" <(E-Mail Removed)> wrote in message >> news:4F8A75AE-B1BA-48DD-A40D-(E-Mail Removed)... >> > Thank you for your excellent suggestion. I do store a path as well as >> > the >> > hyperlink in the database. At first I thougt your suggestion opened up >> > a >> > new, and perhaps more important test than hyperlink validity, namely >> > does >> > the >> > document exist and agree with the name/path in the database. >> > >> > Unfortunately, the documents are on a company ePortal rather than a >> > hard >> > drive and I can't type the path into Windows Explorer and get anywhere. >> > >> > To get to a document I have to open Internet Explorer, go to the >> > ePortal >> > and >> > then click through the folders to navigate to a document. The path >> > that I >> > store in the database cooresponds to the folder heirarchy on the way to >> > a >> > document. I can also click on the stored hyperlink and open the >> > document >> > directly. >> > >> > The hyperlinks start out: https://eportal.companyname... They don't >> > seem >> > to have the path embedded in them. >> > >> > In summary, I don't know how to make your idea work. Also, even if we >> > can >> > use your test to verify the existance and location of the document, a >> > hyperlink validity test would still be useful. >> > >> > Thank again, >> > >> > David >> > >> > >> > "Douglas J. Steele" wrote: >> > >> >> If you can strip the full path out of the hyperlink, you can use >> >> >> >> If Len(Dir(FullPath)) = 0 Then >> >> ' file doesn't exist >> >> Else >> >> ' file exists >> >> End If >> >> >> >> Far faster than opening each instance. >> >> >> >> -- >> >> Doug Steele, Microsoft Access MVP >> >> http://I.Am/DougSteele >> >> (no e-mails, please!) >> >> >> >> >> >> "4110" <(E-Mail Removed)> wrote in message >> >> news:969B61A9-8C87-4DC0-ACD2-(E-Mail Removed)... >> >> >I have a database to manage documents. The database record for each >> >> >document >> >> > includes a hyperlink to the document. WIth the normal changes that >> >> > occur >> >> > over time, some of the links are no longer correct. I would to >> >> > create >> >> > a >> >> > small application that loops through all the records, tests the >> >> > hyperlinks >> >> > and records the invalid links. I know how to follow a hyperlink in >> >> > code >> >> > to >> >> > open the document. If the link is good then I will end up with an >> >> > open >> >> > document. How do I close that document from code? >> >> > >> >> > Thanks, >> >> > >> >> > David >> >> >> >> >> >> >> >> >> |
|
||
|
||||
|
=?Utf-8?B?NDExMA==?=
Guest
Posts: n/a
|
OK - thanks for trying and for the response.
David "Douglas J. Steele" wrote: > Sorry, no suggestions. > > -- > Doug Steele, Microsoft Access MVP > http://I.Am/DougSteele > (no private e-mails, please) > > > "4110" <(E-Mail Removed)> wrote in message > news:1A68B836-BC7E-46C9-8E75-(E-Mail Removed)... > > Thank you for staying with me. I am getting over my head (code wise) so I > > am > > using your code pretty much as is. What I have right now before your code > > is: > > > > With Me.cmdOpenFile > > .HyperlinkAddress = txtHyperLink 'set the hyperlink address > > for the doc > > .Hyperlink.Follow 'follow the > > hyperlink > > to the document > > .HyperlinkAddress = "" 'reset the hyperlink > > address > > End With > > > > This code opens the document by following the hyperlink. I put your code > > behind this and get two errors. > > > > If I click the command button to run the code I get error 429 'ActiveX > > component can't create object'. in line: > > Set objWord = GetObject(, "Word.Application") > > I think it is trying to execute this code before the document is open. > > > > If I put a stop in this line and wait until the document is open before > > proceeding then it executes this line OK and but there is another error > > later > > in line > > objDocument.Close SaveChanges:=0 ' don't save changes > > > > The error is Run-time error 4605. 'This method or property is not > > available > > because the document is in another application.' > > > > Is there a fix? > > > > Thanks, > > > > David > > > > > > > > > > "Douglas J. Steele" wrote: > > > >> Well, it'll be very slow, but you should be able to use the GetObject > >> function to retrieve a reference to the open document. For example, > >> assuming > >> you're dealing with a Word document, you should be able to do something > >> like: > >> > >> Dim objWord As Object > >> Dim objDocument As Object > >> Dim intLoop As Integer > >> > >> Set objWord = GetObject(, "Word.Application") > >> > >> For intLoop = (objWord.Documents.Count - 1) To 0 Step -1 > >> Set objDocument = objWord.Documents(intLoop) > >> objDocument.Close SaveChanges:=0 ' don't save changes > >> Next intLoop > >> > >> objWord.Application.Quit > >> Set objWord = Nothing > >> > >> > >> -- > >> Doug Steele, Microsoft Access MVP > >> http://I.Am/DougSteele > >> (no e-mails, please!) > >> > >> > >> "4110" <(E-Mail Removed)> wrote in message > >> news:4F8A75AE-B1BA-48DD-A40D-(E-Mail Removed)... > >> > Thank you for your excellent suggestion. I do store a path as well as > >> > the > >> > hyperlink in the database. At first I thougt your suggestion opened up > >> > a > >> > new, and perhaps more important test than hyperlink validity, namely > >> > does > >> > the > >> > document exist and agree with the name/path in the database. > >> > > >> > Unfortunately, the documents are on a company ePortal rather than a > >> > hard > >> > drive and I can't type the path into Windows Explorer and get anywhere. > >> > > >> > To get to a document I have to open Internet Explorer, go to the > >> > ePortal > >> > and > >> > then click through the folders to navigate to a document. The path > >> > that I > >> > store in the database cooresponds to the folder heirarchy on the way to > >> > a > >> > document. I can also click on the stored hyperlink and open the > >> > document > >> > directly. > >> > > >> > The hyperlinks start out: https://eportal.companyname... They don't > >> > seem > >> > to have the path embedded in them. > >> > > >> > In summary, I don't know how to make your idea work. Also, even if we > >> > can > >> > use your test to verify the existance and location of the document, a > >> > hyperlink validity test would still be useful. > >> > > >> > Thank again, > >> > > >> > David > >> > > >> > > >> > "Douglas J. Steele" wrote: > >> > > >> >> If you can strip the full path out of the hyperlink, you can use > >> >> > >> >> If Len(Dir(FullPath)) = 0 Then > >> >> ' file doesn't exist > >> >> Else > >> >> ' file exists > >> >> End If > >> >> > >> >> Far faster than opening each instance. > >> >> > >> >> -- > >> >> Doug Steele, Microsoft Access MVP > >> >> http://I.Am/DougSteele > >> >> (no e-mails, please!) > >> >> > >> >> > >> >> "4110" <(E-Mail Removed)> wrote in message > >> >> news:969B61A9-8C87-4DC0-ACD2-(E-Mail Removed)... > >> >> >I have a database to manage documents. The database record for each > >> >> >document > >> >> > includes a hyperlink to the document. WIth the normal changes that > >> >> > occur > >> >> > over time, some of the links are no longer correct. I would to > >> >> > create > >> >> > a > >> >> > small application that loops through all the records, tests the > >> >> > hyperlinks > >> >> > and records the invalid links. I know how to follow a hyperlink in > >> >> > code > >> >> > to > >> >> > open the document. If the link is good then I will end up with an > >> >> > open > >> >> > document. How do I close that document from code? > >> >> > > >> >> > Thanks, > >> >> > > >> >> > David > >> >> > >> >> > >> >> > >> > >> > >> > > > |
|
||
|
||||
|
Alex Dybenko
Guest
Posts: n/a
|
Hi,
try to use ShellExecute API: http://www.mvps.org/access/api/api0018.htm it returns error code, if it can not open file HTH -- Best regards, ___________ Alex Dybenko (MVP) http://alexdyb.blogspot.com http://www.PointLtd.com "4110" <(E-Mail Removed)> wrote in message news:1D227640-797E-46D4-9ECD-(E-Mail Removed)... > OK - thanks for trying and for the response. > > David > > "Douglas J. Steele" wrote: > >> Sorry, no suggestions. >> >> -- >> Doug Steele, Microsoft Access MVP >> http://I.Am/DougSteele >> (no private e-mails, please) >> >> >> "4110" <(E-Mail Removed)> wrote in message >> news:1A68B836-BC7E-46C9-8E75-(E-Mail Removed)... >> > Thank you for staying with me. I am getting over my head (code wise) >> > so I >> > am >> > using your code pretty much as is. What I have right now before your >> > code >> > is: >> > >> > With Me.cmdOpenFile >> > .HyperlinkAddress = txtHyperLink 'set the hyperlink >> > address >> > for the doc >> > .Hyperlink.Follow 'follow the >> > hyperlink >> > to the document >> > .HyperlinkAddress = "" 'reset the hyperlink >> > address >> > End With >> > >> > This code opens the document by following the hyperlink. I put your >> > code >> > behind this and get two errors. >> > >> > If I click the command button to run the code I get error 429 'ActiveX >> > component can't create object'. in line: >> > Set objWord = GetObject(, "Word.Application") >> > I think it is trying to execute this code before the document is open. >> > >> > If I put a stop in this line and wait until the document is open before >> > proceeding then it executes this line OK and but there is another error >> > later >> > in line >> > objDocument.Close SaveChanges:=0 ' don't save changes >> > >> > The error is Run-time error 4605. 'This method or property is not >> > available >> > because the document is in another application.' >> > >> > Is there a fix? >> > >> > Thanks, >> > >> > David >> > >> > >> > >> > >> > "Douglas J. Steele" wrote: >> > >> >> Well, it'll be very slow, but you should be able to use the GetObject >> >> function to retrieve a reference to the open document. For example, >> >> assuming >> >> you're dealing with a Word document, you should be able to do >> >> something >> >> like: >> >> >> >> Dim objWord As Object >> >> Dim objDocument As Object >> >> Dim intLoop As Integer >> >> >> >> Set objWord = GetObject(, "Word.Application") >> >> >> >> For intLoop = (objWord.Documents.Count - 1) To 0 Step -1 >> >> Set objDocument = objWord.Documents(intLoop) >> >> objDocument.Close SaveChanges:=0 ' don't save changes >> >> Next intLoop >> >> >> >> objWord.Application.Quit >> >> Set objWord = Nothing >> >> >> >> >> >> -- >> >> Doug Steele, Microsoft Access MVP >> >> http://I.Am/DougSteele >> >> (no e-mails, please!) >> >> >> >> >> >> "4110" <(E-Mail Removed)> wrote in message >> >> news:4F8A75AE-B1BA-48DD-A40D-(E-Mail Removed)... >> >> > Thank you for your excellent suggestion. I do store a path as well >> >> > as >> >> > the >> >> > hyperlink in the database. At first I thougt your suggestion opened >> >> > up >> >> > a >> >> > new, and perhaps more important test than hyperlink validity, namely >> >> > does >> >> > the >> >> > document exist and agree with the name/path in the database. >> >> > >> >> > Unfortunately, the documents are on a company ePortal rather than a >> >> > hard >> >> > drive and I can't type the path into Windows Explorer and get >> >> > anywhere. >> >> > >> >> > To get to a document I have to open Internet Explorer, go to the >> >> > ePortal >> >> > and >> >> > then click through the folders to navigate to a document. The path >> >> > that I >> >> > store in the database cooresponds to the folder heirarchy on the way >> >> > to >> >> > a >> >> > document. I can also click on the stored hyperlink and open the >> >> > document >> >> > directly. >> >> > >> >> > The hyperlinks start out: https://eportal.companyname... They >> >> > don't >> >> > seem >> >> > to have the path embedded in them. >> >> > >> >> > In summary, I don't know how to make your idea work. Also, even if >> >> > we >> >> > can >> >> > use your test to verify the existance and location of the document, >> >> > a >> >> > hyperlink validity test would still be useful. >> >> > >> >> > Thank again, >> >> > >> >> > David >> >> > >> >> > >> >> > "Douglas J. Steele" wrote: >> >> > >> >> >> If you can strip the full path out of the hyperlink, you can use >> >> >> >> >> >> If Len(Dir(FullPath)) = 0 Then >> >> >> ' file doesn't exist >> >> >> Else >> >> >> ' file exists >> >> >> End If >> >> >> >> >> >> Far faster than opening each instance. >> >> >> >> >> >> -- >> >> >> Doug Steele, Microsoft Access MVP >> >> >> http://I.Am/DougSteele >> >> >> (no e-mails, please!) >> >> >> >> >> >> >> >> >> "4110" <(E-Mail Removed)> wrote in message >> >> >> news:969B61A9-8C87-4DC0-ACD2-(E-Mail Removed)... >> >> >> >I have a database to manage documents. The database record for >> >> >> >each >> >> >> >document >> >> >> > includes a hyperlink to the document. WIth the normal changes >> >> >> > that >> >> >> > occur >> >> >> > over time, some of the links are no longer correct. I would to >> >> >> > create >> >> >> > a >> >> >> > small application that loops through all the records, tests the >> >> >> > hyperlinks >> >> >> > and records the invalid links. I know how to follow a hyperlink >> >> >> > in >> >> >> > code >> >> >> > to >> >> >> > open the document. If the link is good then I will end up with >> >> >> > an >> >> >> > open >> >> >> > document. How do I close that document from code? >> >> >> > >> >> >> > Thanks, >> >> >> > >> >> >> > David >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> |
|
||
|
||||
|
=?Utf-8?B?NDExMA==?=
Guest
Posts: n/a
|
Hi Alex,
Thanks for jumping in. Interesting stuff. I created a new module in my application and dropped in the code you referenced. In my code I substitued the Usage Example (for URL) they gave in the reference, namely: 'Open URL: ?fHandleFile("http://home.att.net/~dashish", WIN_NORMAL) I substituted one of the hyperlinks in my document table. It acted just like my follow hyperlink code. The document opened - and unfortunately, remained open. With a successful open the function return value is -1. I think that indicates success and there seems to be other meaningful possibilities in code. So it all looks good with the exception of the original problem of closing the open document. Thanks, David "Alex Dybenko" wrote: > Hi, > try to use ShellExecute API: > http://www.mvps.org/access/api/api0018.htm > > it returns error code, if it can not open file > > HTH > > -- > Best regards, > ___________ > Alex Dybenko (MVP) > http://alexdyb.blogspot.com > http://www.PointLtd.com > > > "4110" <(E-Mail Removed)> wrote in message > news:1D227640-797E-46D4-9ECD-(E-Mail Removed)... > > OK - thanks for trying and for the response. > > > > David > > > > "Douglas J. Steele" wrote: > > > >> Sorry, no suggestions. > >> > >> -- > >> Doug Steele, Microsoft Access MVP > >> http://I.Am/DougSteele > >> (no private e-mails, please) > >> > >> > >> "4110" <(E-Mail Removed)> wrote in message > >> news:1A68B836-BC7E-46C9-8E75-(E-Mail Removed)... > >> > Thank you for staying with me. I am getting over my head (code wise) > >> > so I > >> > am > >> > using your code pretty much as is. What I have right now before your > >> > code > >> > is: > >> > > >> > With Me.cmdOpenFile > >> > .HyperlinkAddress = txtHyperLink 'set the hyperlink > >> > address > >> > for the doc > >> > .Hyperlink.Follow 'follow the > >> > hyperlink > >> > to the document > >> > .HyperlinkAddress = "" 'reset the hyperlink > >> > address > >> > End With > >> > > >> > This code opens the document by following the hyperlink. I put your > >> > code > >> > behind this and get two errors. > >> > > >> > If I click the command button to run the code I get error 429 'ActiveX > >> > component can't create object'. in line: > >> > Set objWord = GetObject(, "Word.Application") > >> > I think it is trying to execute this code before the document is open. > >> > > >> > If I put a stop in this line and wait until the document is open before > >> > proceeding then it executes this line OK and but there is another error > >> > later > >> > in line > >> > objDocument.Close SaveChanges:=0 ' don't save changes > >> > > >> > The error is Run-time error 4605. 'This method or property is not > >> > available > >> > because the document is in another application.' > >> > > >> > Is there a fix? > >> > > >> > Thanks, > >> > > >> > David > >> > > >> > > >> > > >> > > >> > "Douglas J. Steele" wrote: > >> > > >> >> Well, it'll be very slow, but you should be able to use the GetObject > >> >> function to retrieve a reference to the open document. For example, > >> >> assuming > >> >> you're dealing with a Word document, you should be able to do > >> >> something > >> >> like: > >> >> > >> >> Dim objWord As Object > >> >> Dim objDocument As Object > >> >> Dim intLoop As Integer > >> >> > >> >> Set objWord = GetObject(, "Word.Application") > >> >> > >> >> For intLoop = (objWord.Documents.Count - 1) To 0 Step -1 > >> >> Set objDocument = objWord.Documents(intLoop) > >> >> objDocument.Close SaveChanges:=0 ' don't save changes > >> >> Next intLoop > >> >> > >> >> objWord.Application.Quit > >> >> Set objWord = Nothing > >> >> > >> >> > >> >> -- > >> >> Doug Steele, Microsoft Access MVP > >> >> http://I.Am/DougSteele > >> >> (no e-mails, please!) > >> >> > >> >> > >> >> "4110" <(E-Mail Removed)> wrote in message > >> >> news:4F8A75AE-B1BA-48DD-A40D-(E-Mail Removed)... > >> >> > Thank you for your excellent suggestion. I do store a path as well > >> >> > as > >> >> > the > >> >> > hyperlink in the database. At first I thougt your suggestion opened > >> >> > up > >> >> > a > >> >> > new, and perhaps more important test than hyperlink validity, namely > >> >> > does > >> >> > the > >> >> > document exist and agree with the name/path in the database. > >> >> > > >> >> > Unfortunately, the documents are on a company ePortal rather than a > >> >> > hard > >> >> > drive and I can't type the path into Windows Explorer and get > >> >> > anywhere. > >> >> > > >> >> > To get to a document I have to open Internet Explorer, go to the > >> >> > ePortal > >> >> > and > >> >> > then click through the folders to navigate to a document. The path > >> >> > that I > >> >> > store in the database cooresponds to the folder heirarchy on the way > >> >> > to > >> >> > a > >> >> > document. I can also click on the stored hyperlink and open the > >> >> > document > >> >> > directly. > >> >> > > >> >> > The hyperlinks start out: https://eportal.companyname... They > >> >> > don't > >> >> > seem > >> >> > to have the path embedded in them. > >> >> > > >> >> > In summary, I don't know how to make your idea work. Also, even if > >> >> > we > >> >> > can > >> >> > use your test to verify the existance and location of the document, > >> >> > a > >> >> > hyperlink validity test would still be useful. > >> >> > > >> >> > Thank again, > >> >> > > >> >> > David > >> >> > > >> >> > > >> >> > "Douglas J. Steele" wrote: > >> >> > > >> >> >> If you can strip the full path out of the hyperlink, you can use > >> >> >> > >> >> >> If Len(Dir(FullPath)) = 0 Then > >> >> >> ' file doesn't exist > >> >> >> Else > >> >> >> ' file exists > >> >> >> End If > >> >> >> > >> >> >> Far faster than opening each instance. > >> >> >> > >> >> >> -- > >> >> >> Doug Steele, Microsoft Access MVP > >> >> >> http://I.Am/DougSteele > >> >> >> (no e-mails, please!) > >> >> >> > >> >> >> > >> >> >> "4110" <(E-Mail Removed)> wrote in message > >> >> >> news:969B61A9-8C87-4DC0-ACD2-(E-Mail Removed)... > >> >> >> >I have a database to manage documents. The database record for > >> >> >> >each > >> >> >> >document > >> >> >> > includes a hyperlink to the document. WIth the normal changes > >> >> >> > that > >> >> >> > occur > >> >> >> > over time, some of the links are no longer correct. I would to > >> >> >> > create > >> >> >> > a > >> >> >> > small application that loops through all the records, tests the > >> >> >> > hyperlinks > >> >> >> > and records the invalid links. I know how to follow a hyperlink > >> >> >> > in > >> >> >> > code > >> >> >> > to > >> >> >> > open the document. If the link is good then I will end up with > >> >> >> > an > >> >> >> > open > >> >> >> > document. How do I close that document from code? > >> >> >> > > >> >> >> > Thanks, > >> >> >> > > >> >> >> > David > >> >> >> > >> >> >> > >> >> >> > >> >> > >> >> > >> >> > >> > >> > >> > > |
|
||
|
||||
|
Alex Dybenko
Guest
Posts: n/a
|
Hi David,
have a look here: http://www.mvps.org/access/api/api0025.htm if you know what kind of application will be opened - you can also close it -- Best regards, ___________ Alex Dybenko (MVP) http://alexdyb.blogspot.com http://www.PointLtd.com "4110" <(E-Mail Removed)> wrote in message news:743143FD-ABB3-43A3-B6D1-(E-Mail Removed)... > Hi Alex, > > Thanks for jumping in. > > Interesting stuff. I created a new module in my application and dropped > in > the code you referenced. In my code I substitued the Usage Example (for > URL) > they gave in the reference, namely: > 'Open URL: ?fHandleFile("http://home.att.net/~dashish", > WIN_NORMAL) > > I substituted one of the hyperlinks in my document table. > > It acted just like my follow hyperlink code. The document opened - and > unfortunately, remained open. > > With a successful open the function return value is -1. I think that > indicates success and there seems to be other meaningful possibilities in > code. > > So it all looks good with the exception of the original problem of closing > the open document. > > Thanks, > > David > "Alex Dybenko" wrote: > >> Hi, >> try to use ShellExecute API: >> http://www.mvps.org/access/api/api0018.htm >> >> it returns error code, if it can not open file >> >> HTH >> >> -- >> Best regards, >> ___________ >> Alex Dybenko (MVP) >> http://alexdyb.blogspot.com >> http://www.PointLtd.com >> >> >> "4110" <(E-Mail Removed)> wrote in message >> news:1D227640-797E-46D4-9ECD-(E-Mail Removed)... >> > OK - thanks for trying and for the response. >> > >> > David >> > >> > "Douglas J. Steele" wrote: >> > >> >> Sorry, no suggestions. >> >> >> >> -- >> >> Doug Steele, Microsoft Access MVP >> >> http://I.Am/DougSteele >> >> (no private e-mails, please) >> >> >> >> >> >> "4110" <(E-Mail Removed)> wrote in message >> >> news:1A68B836-BC7E-46C9-8E75-(E-Mail Removed)... >> >> > Thank you for staying with me. I am getting over my head (code >> >> > wise) >> >> > so I >> >> > am >> >> > using your code pretty much as is. What I have right now before >> >> > your >> >> > code >> >> > is: >> >> > >> >> > With Me.cmdOpenFile >> >> > .HyperlinkAddress = txtHyperLink 'set the hyperlink >> >> > address >> >> > for the doc >> >> > .Hyperlink.Follow 'follow the >> >> > hyperlink >> >> > to the document >> >> > .HyperlinkAddress = "" 'reset the >> >> > hyperlink >> >> > address >> >> > End With >> >> > >> >> > This code opens the document by following the hyperlink. I put your >> >> > code >> >> > behind this and get two errors. >> >> > >> >> > If I click the command button to run the code I get error 429 >> >> > 'ActiveX >> >> > component can't create object'. in line: >> >> > Set objWord = GetObject(, "Word.Application") >> >> > I think it is trying to execute this code before the document is >> >> > open. >> >> > >> >> > If I put a stop in this line and wait until the document is open >> >> > before >> >> > proceeding then it executes this line OK and but there is another >> >> > error >> >> > later >> >> > in line >> >> > objDocument.Close SaveChanges:=0 ' don't save changes >> >> > >> >> > The error is Run-time error 4605. 'This method or property is not >> >> > available >> >> > because the document is in another application.' >> >> > >> >> > Is there a fix? >> >> > >> >> > Thanks, >> >> > >> >> > David >> >> > >> >> > >> >> > >> >> > >> >> > "Douglas J. Steele" wrote: >> >> > >> >> >> Well, it'll be very slow, but you should be able to use the >> >> >> GetObject >> >> >> function to retrieve a reference to the open document. For example, >> >> >> assuming >> >> >> you're dealing with a Word document, you should be able to do >> >> >> something >> >> >> like: >> >> >> >> >> >> Dim objWord As Object >> >> >> Dim objDocument As Object >> >> >> Dim intLoop As Integer >> >> >> >> >> >> Set objWord = GetObject(, "Word.Application") >> >> >> >> >> >> For intLoop = (objWord.Documents.Count - 1) To 0 Step -1 >> >> >> Set objDocument = objWord.Documents(intLoop) >> >> >> objDocument.Close SaveChanges:=0 ' don't save changes >> >> >> Next intLoop >> >> >> >> >> >> objWord.Application.Quit >> >> >> Set objWord = Nothing >> >> >> >> >> >> >> >> >> -- >> >> >> Doug Steele, Microsoft Access MVP >> >> >> http://I.Am/DougSteele >> >> >> (no e-mails, please!) >> >> >> >> >> >> >> >> >> "4110" <(E-Mail Removed)> wrote in message >> >> >> news:4F8A75AE-B1BA-48DD-A40D-(E-Mail Removed)... >> >> >> > Thank you for your excellent suggestion. I do store a path as >> >> >> > well >> >> >> > as >> >> >> > the >> >> >> > hyperlink in the database. At first I thougt your suggestion >> >> >> > opened >> >> >> > up >> >> >> > a >> >> >> > new, and perhaps more important test than hyperlink validity, >> >> >> > namely >> >> >> > does >> >> >> > the >> >> >> > document exist and agree with the name/path in the database. >> >> >> > >> >> >> > Unfortunately, the documents are on a company ePortal rather than >> >> >> > a >> >> >> > hard >> >> >> > drive and I can't type the path into Windows Explorer and get >> >> >> > anywhere. >> >> >> > >> >> >> > To get to a document I have to open Internet Explorer, go to the >> >> >> > ePortal >> >> >> > and >> >> >> > then click through the folders to navigate to a document. The >> >> >> > path >> >> >> > that I >> >> >> > store in the database cooresponds to the folder heirarchy on the >> >> >> > way >> >> >> > to >> >> >> > a >> >> >> > document. I can also click on the stored hyperlink and open the >> >> >> > document >> >> >> > directly. >> >> >> > >> >> >> > The hyperlinks start out: https://eportal.companyname... They >> >> >> > don't >> >> >> > seem >> >> >> > to have the path embedded in them. >> >> >> > >> >> >> > In summary, I don't know how to make your idea work. Also, even >> >> >> > if >> >> >> > we >> >> >> > can >> >> >> > use your test to verify the existance and location of the >> >> >> > document, >> >> >> > a >> >> >> > hyperlink validity test would still be useful. >> >> >> > >> >> >> > Thank again, >> >> >> > >> >> >> > David >> >> >> > >> >> >> > >> >> >> > "Douglas J. Steele" wrote: >> >> >> > >> >> >> >> If you can strip the full path out of the hyperlink, you can use >> >> >> >> >> >> >> >> If Len(Dir(FullPath)) = 0 Then >> >> >> >> ' file doesn't exist >> >> >> >> Else >> >> >> >> ' file exists >> >> >> >> End If >> >> >> >> >> >> >> >> Far faster than opening each instance. >> >> >> >> >> >> >> >> -- >> >> >> >> Doug Steele, Microsoft Access MVP >> >> >> >> http://I.Am/DougSteele >> >> >> >> (no e-mails, please!) >> >> >> >> >> >> >> >> >> >> >> >> "4110" <(E-Mail Removed)> wrote in message >> >> >> >> news:969B61A9-8C87-4DC0-ACD2-(E-Mail Removed)... >> >> >> >> >I have a database to manage documents. The database record for >> >> >> >> >each >> >> >> >> >document >> >> >> >> > includes a hyperlink to the document. WIth the normal changes >> >> >> >> > that >> >> >> >> > occur >> >> >> >> > over time, some of the links are no longer correct. I would >> >> >> >> > to >> >> >> >> > create >> >> >> >> > a >> >> >> >> > small application that loops through all the records, tests >> >> >> >> > the >> >> >> >> > hyperlinks >> >> >> >> > and records the invalid links. I know how to follow a >> >> >> >> > hyperlink >> >> >> >> > in >> >> >> >> > code >> >> >> >> > to >> >> >> >> > open the document. If the link is good then I will end up >> >> >> >> > with >> >> >> >> > an >> >> >> >> > open >> >> >> >> > document. How do I close that document from code? >> >> >> >> > >> >> >> >> > Thanks, >> >> >> >> > >> >> >> >> > David >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> |
|
||
|
||||
|
|
|
| |
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Access Close Event: What Order Do Forms Close? | misseill | Microsoft Access | 1 | 14th May 2007 10:03 PM |
| On close or auto close in Access DB | =?Utf-8?B?WFA=?= | Microsoft Access VBA Modules | 1 | 20th Nov 2006 07:20 PM |
| Why excel close all files when I just want to close one files | hon123456 | Microsoft Excel Misc | 1 | 2nd Nov 2005 02:45 PM |
| Have to close Access or wait 10 minutes for ODBC to close | Steve | Microsoft Access External Data | 0 | 21st Jan 2004 02:28 AM |
| Can't Design View or close form, or close Access | Bradley C. Hammerstrom | Microsoft Access Forms | 1 | 23rd Sep 2003 07:23 PM |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc. |




