Results 1 to 2 of 2

Thread: Macro To Connect Word Document To Excel Not Working

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    1
    Rep Power
    0

    Macro To Connect Word Document To Excel Not Working

    Hi,

    I have made a macro in word which have worked perfectly until last week. It is a macro which ensure that the word document is connected to an excel spreadsheet, regardless of whether the files are copied to another folder in a mail merge.

    Do you know what is wrong with the following macro?

    Code:
    Private Sub Document_Open()
    Dim Aktuelsti As String, Saldodata As String
    
    Aktuelsti = ActiveDocument.Path
    
    Saldodata = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "User ID=Admin;" & _
    "Data Source=" & Aktuelsti & "\data.xls;" & _
    "Mode=Read;" & _
    "Extended Properties=""HDR=YES;IMEX=1;"";" & _
    "Jet OLEDB:System database="""";" & _
    "Jet OLEDB:Registry Path="""";" & _
    "Jet OLEDB:Database Passw"
    
    ActiveDocument.MailMerge.OpenDataSource _
    Name:=Aktuelsti & "\data.xls", _
    LinkToSource:=True, _
    Format:=wdOpenFormatAuto, _
    SQLStatement:="SELECT * FROM `Dansk$`", _
    SQLStatement1:="", _
    SubType:=wdMergeSubTypeAccess

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    fjeldgaard, if you can share the entire piece of the code, and also the source files, we could test and try to figure out. Just using your couple of lines above isn't helping.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Word 2010 add-ins not working with macro code
    By mackypogi in forum Word Help
    Replies: 1
    Last Post: 05-29-2014, 12:06 PM
  2. Loop_Find & Copy to word document
    By Excelfun in forum Excel Help
    Replies: 3
    Last Post: 01-14-2014, 10:11 PM
  3. Replies: 1
    Last Post: 05-21-2013, 11:58 AM
  4. Send Outlook Email With Word Document
    By Murali K in forum Excel Help
    Replies: 2
    Last Post: 06-27-2012, 08:42 PM
  5. Excel Macro Functions (GET.DOCUMENT)
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 2
    Last Post: 06-29-2011, 08:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •