Avatar billede flemming39 Nybegynder
13. september 2005 - 18:22 Der er 10 kommentarer og
1 løsning

Opgradering fra 2000 til 2003 - Problemmer med brevfletning

Hej

Jeg forsøger at opgradere en access CRM applikation (2000) til at køre på 2003 men får en fejl i brevfletningen i denne kode:

appWord.activedocument.MailMerge.DataSource.QueryString = iiQuery
appWord.activedocument.MailMerge.Execute


Fejl i første linie: "Det ønskede objekt er ikke til rådighed"

Jeg har ikke erfaring med brevfletning men programmet fungere på "den gamle" platform og jeg kan ikke se hvad som mangler i min opsætning, de virker fuldstændig ens (den gamle og nye platform).

Er der en der kan se hvad jeg mangler at gøre?

ps: spørgsmålet er også oprettet under visual basic, men jeg kom i tanke om at spørgsmålet måske er bedre placeret under access.
Avatar billede terry Ekspert
13. september 2005 - 19:52 #1
hi Flemming

If its worked in 2000 then it should work in 2003.
Are you sure you have a reference to Word in your database? (Tools+REferences)
Avatar billede flemming39 Nybegynder
14. september 2005 - 08:42 #2
I have this reference:
Microsoft word 11.0 object library
But it does'nt work
Avatar billede terry Ekspert
14. september 2005 - 10:02 #3
can we see the rest of the code you use for automation Word?

You must have a document open before you can use activeDocument!


I better add that Word is NOT my strong side :o)
Avatar billede flemming39 Nybegynder
14. september 2005 - 14:19 #4
Hi Terry

For your information.

I have been debugging and the problem is that only holding spaces in :
appword.activedocument.mailmerge.datasource.connectstring = ""
in the old version the connectdtring holds all the right information

I hope to get to a solution soon and youre wery welcome to give me a hint if you have a guees on where the problem is, connections are new to me :-)
Avatar billede terry Ekspert
14. september 2005 - 15:56 #5
so you must have a variable (iiQuery) and it MUST get initialized with something, otherwise it will not  work!
Avatar billede terry Ekspert
14. september 2005 - 15:56 #6
can you see in the old program where it gets initialized?
Avatar billede flemming39 Nybegynder
14. september 2005 - 16:35 #7
Hi Terry

This is the code and the problem is that it seems like the connection not is beeing proberly established. The reason for this point of view is that the connection string is = "" in the 2003 version and correct in the old version like I wrote in my last message.

This is the code:

Function SaveAsWordQ(iTemplate As String, iSaveAs As String, iAuto As Boolean,
iQuery As String)
    Dim appWord As Object
    Dim iiQuery As String

    Set appWord = CreateObject("Word.Application")
    appWord.Visible = Not iAuto
    If Not IsNull(iTemplate) And (iTemplate <> "") Then
        appWord.Documents.Open (iTemplate)
    Else
        appWord.Documents.Add
    End If

    If appWord.activedocument.Bookmarks.exists("Dagsdato") Then
        appWord.activedocument.Bookmarks("Dagsdato").Select
        appWord.selection.Text = Format(Date, "dd/mm-yyyy")
    End If
    If appWord.activedocument.Bookmarks.exists("Dagsdato2") Then
        appWord.activedocument.Bookmarks("Dagsdato2").Select
        appWord.selection.Text = Format(Date, "dd/mm-yyyy")
    End If
   
    If Not IsNull(iTemplate) And (iTemplate <> "") Then
        iiQuery = iQuery
        If InStr(iQuery, "SELECT") = 0 Then
            If InStr(iQuery, "WHERE") = 0 Then
                If iQuery = "" Then
                    iiQuery = "SELECT" _
                        & " ..............."
                Else   
                    iiQuery = "SELECT" _
                        & " ....................."
                End If
            Else 
                iiQuery = "SELECT" _
                    & " ......................"
            End If
        End If
'MsgBox (iiQuery)
        appWord.activedocument.MailMerge.DataSource.QueryString = iiQuery
        appWord.activedocument.MailMerge.Execute
    End If
   
    appWord.activedocument.SaveAs FileName:=iSaveAs, FileFormat:=wdFormatRTF
   
    If Not IsNull(iTemplate) And (iTemplate <> "") Then
        If iAuto Then
            appWord.activedocument.PrintOut
            appWord.activedocument.Close
        End If
   
        appWord.Documents(iTemplate).Activate
        appWord.activedocument.Saved = True
        appWord.activedocument.Close
   
        If Not iAuto Then
            appWord.Documents(iSaveAs).Activate
        End If
    End If

'    appWord.Quit

End Function
Avatar billede flemming39 Nybegynder
14. september 2005 - 16:54 #8
I think i might have found something about the problem here here:

8/19/2005 11:31:36 AM    Re: Problem with Word Code in 2003
Hi Neil, 
 
See this article 
 
"Opening This Will Run the Following SQL Command" Message When You Open a Word 
 
Document - 825765 
 
http://support.microsoft.com?kbid=825765 
 
When you automate opening a Word main merge document, the link to the data 
 
source is cut off without warning you. You either have to use .OpenDataSource 
 
after opening the document, or make sure the Registry key is set to disable 
 
the security question. 
 
Cindy Meister 
 
INTER-Solutions, Switzerland 
 
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004) 
 
http://www.word.mvps.org 
 
This reply is posted in the Newsgroup; please post any follow question or 
 
reply in the newsgroup and not by e-mail :-)
Avatar billede terry Ekspert
14. september 2005 - 19:53 #9
I think I would need to see the code which calls the function as there are a number of variables which will need initializing before the call.

I could maybe look at your database if you like? Otherwsie its going to be hard to pinpoint the problem.

eksperten@NOSPAMsanthell.dk

Remove NOSPAM
Avatar billede flemming39 Nybegynder
15. september 2005 - 10:18 #10
Jeg skal i aften have afprøvet om jeg ved at "genatablere" datasource i mit activedocumnet kan komme videre.

Jeg passer mit "almindelige" arbejde i dag :-)
Avatar billede flemming39 Nybegynder
26. oktober 2005 - 09:47 #11
Undskyld den manglende fortsættelse men....
Jeg lukker spørgsmålet nu....
Jeg er i gang med noget andet lige nu og har simpelthen ikke tid og energi til at arbejde mod en løsning lige nu. Genåbner muligvis spørgsmålet senere.
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
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

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