Avatar billede anders-kaas Novice
19. juli 2012 - 16:07 Der er 14 kommentarer og
1 løsning

Access Re-link Excel

Jeg har linket et regneark (NyLinkSti, fanen "Priser") til en tabel (Datatabel) og ønsker at ændre det til et andet regneark.
og bruger følgende:

CurrentDb.TableDefs("Datatabel").Connect = "Excel 8;Database = " & NyLinkSti & "\Priser$"

CurrentDb.TableDefs("Datatabel").RefreshLink

Den kører igennem uden fejl, men ændre ikke linket.

Jeg bruger Office 2010

Hvad skal jeg gøre ?
Avatar billede terry Ekspert
19. juli 2012 - 18:36 #1
try deleting the linked table first and then create new
Avatar billede anders-kaas Novice
19. juli 2012 - 19:14 #2
If I do that, links to other table will not work
Avatar billede terry Ekspert
19. juli 2012 - 19:48 #3
?
What other table?

If you delete first and then create new which one do you mean is other table?
Avatar billede anders-kaas Novice
19. juli 2012 - 20:35 #4
I have an query
If I remove the table an replace it with an other with the same name ofcause, I will get an dialogbox, asking for input in the first field in the table when I open it, and the table is emty
Avatar billede terry Ekspert
19. juli 2012 - 21:13 #5
Doesnt the second table contain same column names?
Avatar billede terry Ekspert
19. juli 2012 - 21:14 #6
You also have another question http://www.eksperten.dk/spm/965030 which you need to looke at :o)
Avatar billede anders-kaas Novice
19. juli 2012 - 21:20 #7
Yes it is the same just with different data
Avatar billede terry Ekspert
20. juli 2012 - 18:47 #8
Hi Anders If I get time over the weekend then I'll see if I can put some code together for which which hopefully works.
Avatar billede anders-kaas Novice
21. juli 2012 - 15:18 #9
Like that :-)
If You need my files you can mail my at Anders@kaas.at and I will send them to you.
Avatar billede terry Ekspert
22. juli 2012 - 09:18 #10
I have sent you an email
Avatar billede terry Ekspert
22. juli 2012 - 10:58 #11
do you get prompted to first convert to 2002 - 2003 format?

You have to do that first before youare allowed to make an MDE
Avatar billede terry Ekspert
22. juli 2012 - 11:26 #12
I have actually found out what the problem is.

In code view try compiling the database (debug + compile ...)

You get an error in module moduler! You need to alter this code so that you dont get an error then you will be able to make your MDE. :o)
Avatar billede terry Ekspert
16. august 2012 - 15:34 #13
did this solve the problem Anders?
Avatar billede anders-kaas Novice
27. august 2012 - 20:40 #14
Thanks the solution was perfect

Thank you for a lot of work :-)

Function RecreateLink(sTableName, sFileName) As Boolean


On Error GoTo Err_Handler

Dim sConnect As String
Dim sTable As String

    With CurrentDb
   
        On Error Resume Next
        With .TableDefs(sTableName)
            sConnect = .Connect
            sTable = .SourceTableName
        End With
       
     
        .TableDefs.Delete sTableName
       
        On Error GoTo Err_Handler
        DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel8, sTableName, sFileName, False, "Ark2!A1:G25"

    End With

    RecreateLink = True

    Exit Function
Avatar billede terry Ekspert
27. august 2012 - 21:08 #15
thank you
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester