Results 1 to 16 of 16

Thread: Specify Table Name [Resolved]

  1. #1

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Resolved 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.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Specify Table Name [Resolved]

    yes. i see the connection: object. i think that's it

  4. #4

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Specify Table Name [Resolved]

    hmm. it is still asking. oops. changed the wrong one.

  5. #5

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Specify Table Name [Resolved]

    Plus, I don't want to be prompted to save the .dot file. How do i do that?

  6. #6

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Specify Table Name [Not Quite Resolved]

    Oops. I still need help. I said the Connection was "Table David"
    and it still asks!

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  8. #8

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Specify Table Name [Not Quite Resolved]

    VB Code:
    1. Dim oDoc As Word.Document
    2.     moApp.Visible = True
    3.     Set oDoc = moApp.Documents.Add("D:\Test.dot", , , True)
    4.     With oDoc.MailMerge
    5.         .MainDocumentType = wdFormLetters
    6.         .OpenDataSource Name:="D:\RobDog888.mdb", LinkToSource:=True, Connection:="TABLE ClientData"
    7.     End With
    8.     With oDoc.MailMerge.DataSource
    9.         .FirstRecord = 1
    10.         .LastRecord = 20
    11.     End With
    12.     With oDoc.MailMerge
    13.         .Destination = wdSendToPrinter 'wdSendToNewDocument; wdSendToFax; wdSendToEmail
    14.         .Execute True
    15.     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.

  9. #9

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Dim oDoc As Word.Document
    5.     moApp.Visible = True
    6.     Set oDoc = moApp.Documents.Add("D:\Test.dot", , , True)
    7.     With oDoc.MailMerge
    8.         .MainDocumentType = wdFormLetters
    9.         .OpenDataSource Name:="D:\RobDog888.mdb", LinkToSource:=True, Connection:="TABLE ClientData"
    10.     End With
    11.     With oDoc.MailMerge.DataSource 'If you want to specify a range of records
    12.         .FirstRecord = 1
    13.         .LastRecord = 20
    14.     End With
    15.     With oDoc.MailMerge
    16.         .Destination = wdSendToPrinter 'wdSendToNewDocument; wdSendToFax; wdSendToEmail
    17.         .Execute True
    18.     End With
    19.     oDoc.Close False
    20.     Set oDoc = Nothing
    21.     moApp.Quit
    22.     Set moApp = Nothing
    23. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  11. #11

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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:
    1. With oDoc.MailMerge.DataSource   '
    2.         .FirstRecord = 1                                   '
    3.         .LastRecord = 3                                   '
    4.     End With                                                '
    5.     With oDoc.MailMerge
    6.         .Destination = wdSendToPrinter 'wdSendToNewDocument;wdSendToPrinter; wdSendToFax; wdSendToEmail
    7. '        .Destination = wdSendToNewDocument 'wdSendToNewDocument;wdSendToPrinter; wdSendToFax; wdSendToEmail
    8.         .Execute True
    9.     End With
    10.     '
    11.     oDoc.Close False
    12.     Set oDoc = Nothing
    13.     moApp.Quit
    14.     Set moApp = Nothing

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  13. #13

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Specify Table Name [Not Quite Resolved]

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Dim oDoc As Word.Document
    5.     Dim oMMDoc As Word.Document
    6.     moApp.Visible = True
    7.     Set oDoc = moApp.Documents.Add("D:\Test.dot", , , True)
    8.     With oDoc.MailMerge
    9.         .MainDocumentType = wdFormLetters
    10.         .OpenDataSource Name:="D:\RobDog888.mdb", LinkToSource:=True, Connection:="TABLE ClientData"
    11.     End With
    12.     With oDoc.MailMerge.DataSource 'If you want to specify a range of records
    13.         .FirstRecord = 1
    14.         .LastRecord = .RecordCount
    15.     End With
    16.     With oDoc.MailMerge
    17.         .Destination = wdSendToPrinter 'wdSendToNewDocument; wdSendToFax; wdSendToEmail
    18.         .Execute True
    19.     End With
    20.     oDoc.Close False
    21.     'Either method shoud work depending that the documents collection only had the template and the mm doc
    22.     'also if you dont need to do anything with it then the one liner would be best
    23.     'moApp.Documents(1).Close False
    24.     'Method two
    25.     'Set oMMDoc = moApp.Documents(1)
    26.     'oMMDoc.Close False
    27.     'Set oMMDoc = Nothing
    28.     Set oDoc = Nothing
    29.     moApp.Quit
    30.     Set moApp = Nothing
    31. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  15. #15

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Specify Table Name [Not Quite Resolved]

    that looks real good. thanks.

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width