|
-
Feb 15th, 2005, 03:42 PM
#1
Specify Table Name [Resolved]
In my DB, how do I link to the table named DAVID. Right now, Word asks for the table, and presents a list of all the tables in MyDB.
Thanks.
Last edited by dglienna; Feb 15th, 2005 at 05:28 PM.
-
Feb 15th, 2005, 03:45 PM
#2
Re: Specify Table Name
David, is your "DAVID" table in the list that is presented?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2005, 03:47 PM
#3
Re: Specify Table Name [Resolved]
yes. i see the connection: object. i think that's it
-
Feb 15th, 2005, 03:49 PM
#4
Re: Specify Table Name [Resolved]
hmm. it is still asking. oops. changed the wrong one.
-
Feb 15th, 2005, 03:50 PM
#5
Re: Specify Table Name [Resolved]
Plus, I don't want to be prompted to save the .dot file. How do i do that?
-
Feb 15th, 2005, 03:56 PM
#6
Re: Specify Table Name [Not Quite Resolved]
Oops. I still need help. I said the Connection was "Table David"
and it still asks!
-
Feb 15th, 2005, 04:03 PM
#7
Re: Specify Table Name [Not Quite Resolved]
Where is the code you were using?
When you open the template in code you can specify readonly, I think, and
in the close method you can specify False as the save changes argument.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2005, 04:04 PM
#8
Re: Specify Table Name [Not Quite Resolved]
VB Code:
Dim oDoc As Word.Document
moApp.Visible = True
Set oDoc = moApp.Documents.Add("D:\Test.dot", , , True)
With oDoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:="D:\RobDog888.mdb", LinkToSource:=True, Connection:="TABLE ClientData"
End With
With oDoc.MailMerge.DataSource
.FirstRecord = 1
.LastRecord = 20
End With
With oDoc.MailMerge
.Destination = wdSendToPrinter 'wdSendToNewDocument; wdSendToFax; wdSendToEmail
.Execute True
End With
I need a CLOSE statement also. Do I have to specify the first and last record? If I create a document, how do I close that by giving it a static name?
Well, it needs the SQL statement. http://support.microsoft.com/kb/289830
Last edited by dglienna; Feb 15th, 2005 at 04:11 PM.
-
Feb 15th, 2005, 04:17 PM
#9
Re: Specify Table Name [Not Quite Resolved]
OK. One down, and three to go.
I need a CLOSE statement also.
Do I have to specify the first and last record?
If I create a document, how do I close that by giving it a static name?
Thanks.
-
Feb 15th, 2005, 04:18 PM
#10
Re: Specify Table Name [Not Quite Resolved]
We have set a document object equal to the instance of "Document1". so we can
close just that document any time we want like this.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim oDoc As Word.Document
moApp.Visible = True
Set oDoc = moApp.Documents.Add("D:\Test.dot", , , True)
With oDoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:="D:\RobDog888.mdb", LinkToSource:=True, Connection:="TABLE ClientData"
End With
With oDoc.MailMerge.DataSource 'If you want to specify a range of records
.FirstRecord = 1
.LastRecord = 20
End With
With oDoc.MailMerge
.Destination = wdSendToPrinter 'wdSendToNewDocument; wdSendToFax; wdSendToEmail
.Execute True
End With
oDoc.Close False
Set oDoc = Nothing
moApp.Quit
Set moApp = Nothing
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2005, 04:38 PM
#11
Re: Specify Table Name [Not Quite Resolved]
1) It won't let me comment out the range for first and last doc. I tried to comment out the 4 lines (including the with)
2) Doc 2 (the merged document is still left open if i choose mergetonewdoc. should i leave it open?
VB Code:
With oDoc.MailMerge.DataSource '
.FirstRecord = 1 '
.LastRecord = 3 '
End With '
With oDoc.MailMerge
.Destination = wdSendToPrinter 'wdSendToNewDocument;wdSendToPrinter; wdSendToFax; wdSendToEmail
' .Destination = wdSendToNewDocument 'wdSendToNewDocument;wdSendToPrinter; wdSendToFax; wdSendToEmail
.Execute True
End With
'
oDoc.Close False
Set oDoc = Nothing
moApp.Quit
Set moApp = Nothing
-
Feb 15th, 2005, 04:43 PM
#12
Re: Specify Table Name [Not Quite Resolved]
You can attach a document object to the merge result document or you can reference it by name
in the documents collection. For the range you can use you ADO recordset recordcount as the last
record unless you only need a few records. If you are printing directly then close the docs. If you
are emailing automatically then close else leave, etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2005, 04:52 PM
#13
Re: Specify Table Name [Not Quite Resolved]
I did a special query to get the record count previously, and placed it in another table. Is there an easier way? I have a sql string to get the records as * from David. Is there a way to get the count then?
I'm not sure that I follow you about the object, or Document collection.
Would I just use Document 2 for the merged document? How to refer to it by name? (It seems to be called Letter2, and just 2 when I save it)
Thanks for the help...
Last edited by dglienna; Feb 15th, 2005 at 05:06 PM.
-
Feb 15th, 2005, 05:08 PM
#14
Re: Specify Table Name [Not Quite Resolved]
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim oDoc As Word.Document
Dim oMMDoc As Word.Document
moApp.Visible = True
Set oDoc = moApp.Documents.Add("D:\Test.dot", , , True)
With oDoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:="D:\RobDog888.mdb", LinkToSource:=True, Connection:="TABLE ClientData"
End With
With oDoc.MailMerge.DataSource 'If you want to specify a range of records
.FirstRecord = 1
.LastRecord = .RecordCount
End With
With oDoc.MailMerge
.Destination = wdSendToPrinter 'wdSendToNewDocument; wdSendToFax; wdSendToEmail
.Execute True
End With
oDoc.Close False
'Either method shoud work depending that the documents collection only had the template and the mm doc
'also if you dont need to do anything with it then the one liner would be best
'moApp.Documents(1).Close False
'Method two
'Set oMMDoc = moApp.Documents(1)
'oMMDoc.Close False
'Set oMMDoc = Nothing
Set oDoc = Nothing
moApp.Quit
Set moApp = Nothing
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2005, 05:27 PM
#15
Re: Specify Table Name [Not Quite Resolved]
that looks real good. thanks.
-
Feb 15th, 2005, 05:30 PM
#16
Re: Specify Table Name [Resolved]
No prob. 
Ps, I dont like using MM's so I appologise for the limited examples. Guess if I
was more into them I could do more.
Later
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|