Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Posts
    225

    Unanswered: Database to stay visible behind Followhyperlink

    i am not sure the title of this thread explains mu problem too well.

    i have a form that has a button on it, when clicked a link to a word document is activated using the followhyperlink option.

    The word document opens fine but here is my problem, when i close the word document my database has minimised and is not visible unless i go down to the bottom bar and click on the db to then maximise it.

    hope this makes sense.....

    what i want to happen is, when i click on the the close option of the word document, that the form that triggered the open document would be visible.

    cheers

    Andy

  2. #2
    Join Date
    Mar 2004
    Location
    Glasgow, Scotland
    Posts
    107
    I get this to work in Access 2000 without the aforementioned problem. Try setting the forms Modal property to Yes...The other thing I do is hide the Word document until after it has been populated with data from the database, then I make it visible.

  3. #3
    Join Date
    Mar 2003
    Posts
    225
    ok thanks will have a go, but how do i do this bit please
    The other thing I do is hide the Word document until after it has been populated with data from the database, then I make it visible.
    cheers

    Andy

  4. #4
    Join Date
    Mar 2004
    Location
    Glasgow, Scotland
    Posts
    107
    Here's the code I use to open a Word document from the hyperlink:

    Private Sub txtProposal_FileName_DblClick(Cancel As Integer)

    Dim objProposal As Word.Application

    Set objProposal = New Word.Application

    objProposal.Documents.Open strApplicationPath & "\Docs\Proposals\" & Me.txtProposal_FileName
    objProposal.Visible = True

    DoCmd.Close 'You don't want to do this, this will close your form.

    End Sub

    Here's the code I use to populate a word template with data from the database in the first place. (i'm assuming that u know how to create bookmarks in Word):

    Option Compare Database

    Private Sub cmdCreateProposal_Click()
    On Error GoTo Err_cmdCreateProposal_Click

    Dim strProposalFileLocation As String
    Dim strProposalFileName As String
    Dim intAns As Integer

    intAns = MsgBox("Are you sure?", vbYesNo)

    If intAns = vbNo Then

    Exit Sub

    End If

    Set objProposal = New Word.Application

    objProposal.Documents.Add strApplicationPath & "\Docs\Templates\ADS Customer Proposal.dot"
    objProposal.Visible = False

    With objProposal.ActiveDocument.Bookmarks

    If IsNull(Me.txtProposal_Title) = False Then

    .Item("proposalTitle").Range.Text = Me.txtProposal_Title.Value

    End If

    If IsNull(Me.txtProposal_Date) = False Then

    .Item("proposalDate").Range.Text = FormatDateTime(Me.txtProposal_Date.Value, [vbLongDate])

    End If

    End With

    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''
    'The code below adds the proposal title to the header page of the document. '
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''

    If objProposal.ActiveWindow.View.SplitSpecial <> wdPaneNone Then

    objProposal.ActiveWindow.Panes(2).Close

    End If

    If objProposal.ActiveWindow.ActivePane.View.Type = wdNormalView Or objProposal.ActiveWindow.ActivePane.View.Type = wdOutlineView Then

    objProposal.ActiveWindow.ActivePane.View.Type = wdPrintView

    End If

    objProposal.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

    If IsNull(Me.txtProposal_Title) = False Then

    objProposal.ActiveDocument.Bookmarks.Item("proposa lHeaderTitle").Range.Text = Me.txtProposal_Title.Value

    End If

    If IsNull(Me.txtProposal_RefNo) = False Then

    objProposal.ActiveDocument.Bookmarks.Item("proposa lRefNo").Range.Text = Me.txtProposal_RefNo.Value

    End If

    objProposal.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''
    'The code ends here. '
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''

    strProposalFileLocation = strApplicationPath & "\Docs\Proposals\" & Me.txtProposal_RefNo

    objProposal.ActiveDocument.SaveAs FileName:=strProposalFileLocation, FileFormat:=wdFormatDocument, _
    LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
    :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
    False

    Me.txtProposal_FileName.Value = Me.txtProposal_RefNo & ".doc"
    objProposal.Visible = True
    DoCmd.Close
    Form_frmOpportunity.lstProposals.Requery

    Exit_cmdCreateProposal_Click:
    Exit Sub

    Err_cmdCreateProposal_Click:
    MsgBox Err.Description
    Resume Exit_cmdCreateProposal_Click

    End Sub

    Don't know if any of this helps...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •