Open Dialog Box... HELP

A

awrex

I'm trying to tweak a MSDN Article that allows me to import data from a Word
form to a Access db.... I'm wanting to have a directory open dialog box pop
open and feel i've traveled into hositle waters on this..... Your help is
appreciated!!!



Sub GetWordData()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strDocName As String
Dim blnQuitWord As Boolean
Dim d As FileDialog


On Error GoTo ErrorHandling

strDocName = "C:\Documents and Settings\chavira\Desktop\CPD\" & _
InputBox("Enter the name of the Word contract " & _
"you want to import:", "Import Contract")

Set appWord = GetObject(, "Word.Application")
Set doc = appWord.Documents.Open(strDocName)

cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\My Documents\" & _
"CPD Form.mdb;"
rst.Open "CPD_Table", cnn, _
adOpenKeyset, adLockOptimistic
 
D

Doug Robbins - Word MVP

With Dialogs(wdDialogFileOpen) .Show

End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Doug Robbins - Word MVP

Hit send a bit too soon

With Dialogs(wdDialogFileOpen)
.Show
End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

awrex

Hi Doug...

Would I add that in this section someplace??? I'd want to replace the
InputBox for the Directory option (Open Dialog)...

THANK YOU for your help!!!
 
D

Doug Robbins - Word MVP

Use:

With Dialogs(wdDialogFileOpen)
If .Display = -1 then
strDocName = .Name
End if
End with

Set appWord = GetObject(, "Word.Application")
Set doc = appWord.Documents.Open(strDocName)


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top