With Dialogs/ Word bookmarks

gpurger

Registered User.
Local time
Yesterday, 19:07
Joined
Apr 21, 2004
Messages
66
Hi,
I am trying to let the user open a chosen word file.
I can activate word but I am having problems displaying the 'Open Dialog' to allow them to choose.
The file will be a Word .doc with bookmarks that I want to save to a table.

Can anyone point me in the right direction please?

Cheers
 
Don't use the Word-FileOpen Dialog.
Get the Filename and location in Access and use the Filename as Parameter for the OpenDocument-Method of Word

dim objDoc as word.document
dim wdBkmrk as word.bookmark

for each wdBkmrk in objdoc.bookmarks
DAO-commands to create records of
bookmarks in your database
next

does this help. Please post further questions. I will have time in the afternoon today to post again.
Christoph
 
Thanks,
I only am trying to open the doc via Word because I can not find how to open it in Access.
Remember it can have any name.
Cheers for your help
 
Sorry, I had to change plans yesterday.

This is the code I use in a class to extract the Bookmarks into a collection

Code:
Public Function GetDocumentBookmarks(ByVal strFilename As String) As Collection
    
    On Error GoTo Fehler
    
    Dim bkmrk As Object
    Dim colBookmarks As New Collection
    
    OpenDoc strFilename
    For Each bkmrk In mDocument.Bookmarks
        colBookmarks.Add Item:=bkmrk.Name
    Next

    Set GetDocumentBookmarks = colBookmarks
    
ExitHere:
    On Error Resume Next
    Set colBookmarks = Nothing
    Exit Function

Fehler:
    Resume ExitHere
    Resume 'testing only
End Function

Then I work with the resulting collection:

Code:
    Set colBookmarks = GetWord.GetDocumentBookmarks(Me.DocTemplate)
    If colBookmarks.Count = 0 Then
        Set colBookmarks = Nothing
        MsgBox "Es sind keine Textmarken im Dokument vorhanden.", vbExclamation, GetProject.AppTitel
        Exit Sub
    End If
    
    strSQL = "UPDATE tkey_wdBookmark Set BookmarkExists = 0 WHERE fiDocument = " & Me.cboDocument
    CurrentDb.Execute strSQL
    
    strSQL = "SELECT * FROM tkey_wdBookmark"
    Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
    
    For i = 1 To colBookmarks.Count
        If fcDomWert("BookmarkName", "tkey_wdBookmark", "fiDocument = " & Me.cboDocument & " AND BookmarkName = '" & colBookmarks.Item(i) & "'", ltDCount) = 0 Then
            rs.AddNew
            rs.Fields("fiDocument") = Me.cboDocument
            rs.Fields("BookmarkName") = colBookmarks.Item(i)
            rs.Fields("BookmarkSort") = Nz(fcDomWert("BookmarkSort", "tkey_wdBookmark", "fiDocument = " & Me.cboDocument, ltDMax), 0) + 1
            rs.Fields("BookmarkExists") = True
            rs.Update
        Else
            strSQL = "UPDATE tkey_wdBookmark Set BookmarkExists = TRUE WHERE fiDocument = " & Me.cboDocument & " AND BookmarkName = '" & colBookmarks.Item(i) & "'"
            CurrentDb.Execute strSQL
        End If
    Next i

You may look at http://support.microsoft.com/default.aspx?scid=kb;en-us;288543 to find Information on getting a valid filename as a parameter for MS Word

Christoph
 

Users who are viewing this thread

Back
Top Bottom