Hi, Todd.
Is it possible to set Database properties:Hyperlinkbase in code?
Yes. First, set a reference to the Microsoft Office Object library, then
paste the following code into a standard module, alter the path and file name
and the Hyperlink Base in the example to suit your needs, save the module and
compile the code:
Public Sub testHyplinkbase()
On Error GoTo ErrHandler
Dim fSuccess As Boolean
fSuccess = setHyperlinkBase("C:\Test\MyDB.mdb", "C:\NeverUseSendKeys\")
MsgBox "Set the Hyperlink base = " & fSuccess
Exit Sub
ErrHandler:
MsgBox "Error in testHyplinkbase( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear
End Sub
Public Function setHyperlinkBase(sPath As String, sHyperlinkBase As String)
As Boolean
On Error GoTo ErrHandler
Dim AccApp As New Access.Application
Dim CmdBar As CommandBar
Dim CmdBarPopup As CommandBarPopup
AccApp.OpenCurrentDatabase sPath, True
Set CmdBar = AccApp.CommandBars("Menu Bar")
Set CmdBarPopup = CmdBar.Controls("File")
SendKeys "%H" & sHyperlinkBase & "~", False
CmdBarPopup.Controls("Database Properties").accDoDefaultAction
setHyperlinkBase = True ' Success.
CleanUp:
Set CmdBarPopup = Nothing
Set CmdBar = Nothing
AccApp.Quit
Set AccApp = Nothing
Exit Function
ErrHandler:
MsgBox "Error in setHyperlinkBase( )" & vbCrLf & _
"in SetupDB module." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
setHyperlinkBase = False ' Failure.
GoTo CleanUp
End Function ' setHyperlinkBase( )
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.