Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

Open Dialog Box... HELP

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
awrex - 05 Mar 2007 19:19 GMT
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
Doug Robbins - Word MVP - 05 Mar 2007 20:45 GMT
With Dialogs(wdDialogFileOpen)    .Show

End With

Signature

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

> I'm trying to tweak a MSDN Article that allows me to import data from a
> Word
[quoted text clipped - 26 lines]
> rst.Open "CPD_Table", cnn, _
>    adOpenKeyset, adLockOptimistic
Doug Robbins - Word MVP - 05 Mar 2007 20:46 GMT
Hit send a bit too soon

With Dialogs(wdDialogFileOpen)
   .Show
End With

Signature

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

> I'm trying to tweak a MSDN Article that allows me to import data from a
> Word
[quoted text clipped - 26 lines]
> rst.Open "CPD_Table", cnn, _
>    adOpenKeyset, adLockOptimistic
awrex - 05 Mar 2007 21:08 GMT
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!!!

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

> Hit send a bit too soon
>
[quoted text clipped - 32 lines]
> > rst.Open "CPD_Table", cnn, _
> >    adOpenKeyset, adLockOptimistic
Doug Robbins - Word MVP - 06 Mar 2007 07:17 GMT
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)

Signature

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

> Hi Doug...
>
[quoted text clipped - 44 lines]
>> > rst.Open "CPD_Table", cnn, _
>> >    adOpenKeyset, adLockOptimistic
awrex - 06 Mar 2007 16:06 GMT
WOO HOO!!

Thanks Doug!! Now I need to fix the DB error that I'm getting...

> Use:
>
[quoted text clipped - 55 lines]
> >> > rst.Open "CPD_Table", cnn, _
> >> >    adOpenKeyset, adLockOptimistic
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.