Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820

    Unanswered: Why the F**K ain't this working

    amazing how much more notice poeple take of a post with F**K in the title.

    anyhow i get as far as "test 2" being shown and then the computer locks up, hour glass only process running is idle and the Investigation.doc is corrupted when i CTRL ALT DEL the task
    Code:
    Sub Test()
        On Error GoTo a
        Dim wrd As Object, inv As Word.Document
        MsgBox "TEST 1"
        Set wrd = New Word.Application
        MsgBox "TEST 2"
        Set inv = wrd.Documents.Open("j:\Investigation.doc")
        MsgBox "TEST 3"
        With inv.MailMerge
            .Destination = wdSendToPrinter
            MsgBox "TEST 4"
            .Execute
        End With
    b:  Exit Sub
    
    a:  MsgBox Err.Description
        Resume b
    End Sub
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  2. #2
    Join Date
    Feb 2002
    Location
    San Antonio, TX
    Posts
    69
    This code tested fine for me with A97 & NT4 workstation. You must have some unwanted funk on your system.
    "Doing stuff is overrated. Take Hitler for example. He did lots but don't we all wish he'd have just stayed home and gotten stoned?"

  3. #3
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173

    Re: Why the F**K ain't this working

    Ye the word f**k seems to get most peoples attention. I tested the code. It worked the first time. Then I ran it again and it hung. Rebooted the machine... ran it again worked fine the first time, clicked button again ... and it hung ...

    Is it the same for you ....???? If so ... the document is open in memory and there is a message box hidden somewhere ... "blah blah blah ... would you like to open it as read only" ...

    This may be your problem ... was mine ...

    Originally posted by m.timoney
    amazing how much more notice poeple take of a post with F**K in the title.

    anyhow i get as far as "test 2" being shown and then the computer locks up, hour glass only process running is idle and the Investigation.doc is corrupted when i CTRL ALT DEL the task
    Code:
    Sub Test()
        On Error GoTo a
        Dim wrd As Object, inv As Word.Document
        MsgBox "TEST 1"
        Set wrd = New Word.Application
        MsgBox "TEST 2"
        Set inv = wrd.Documents.Open("j:\Investigation.doc")
        MsgBox "TEST 3"
        With inv.MailMerge
            .Destination = wdSendToPrinter
            MsgBox "TEST 4"
            .Execute
        End With
    b:  Exit Sub
    
    a:  MsgBox Err.Description
        Resume b
    End Sub

  4. #4
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    try adding a inv.close

    i didn't bother with it as i couldnt get that far, i'll try it on after a reboot, just to be sure
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  5. #5
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173
    OK gave it a try again, using access 2000, and it did hang ....
    try this for size and see what happens

    Sub Test()
    On Error GoTo err_line
    Dim wdApp As New Word.Application
    Dim wdDoc As Word.Document

    MsgBox "TEST 1"
    Set wrd = New Word.Application

    MsgBox "TEST 2"
    Set wdDoc = wdApp.Documents.Open("c:\temp\test.doc")

    MsgBox "TEST 3"
    With wdDoc.MailMerge
    .Destination = wdSendToPrinter
    MsgBox "TEST 4"
    .Execute
    End With

    wdDoc.Close

    Exit Sub

    err_line:
    MsgBox Err.Description
    wdDoc.Close
    Set wdApp = Nothing
    Exit Sub

    End Sub

    This did not hang for me at all ...

    Originally posted by m.timoney
    try adding a inv.close

    i didn't bother with it as i couldnt get that far, i'll try it on after a reboot, just to be sure
    Mona
    ________________________________
    Life is too short to be sane or sensible. Weird people rule and normal people suck

  6. #6
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    great it's working and all i had to do was upgrade to office XP,

    now Why the hell do the following errors occur, on the .execute line
    Attached Thumbnails Attached Thumbnails screen.jpg  
    Last edited by m.timoney; 12-11-02 at 08:19.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  7. #7
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    and type mismatch when code edited to:
    Code:
    Option Compare Database
    Option Explicit
    
    Sub Test()
        'On Error GoTo a
        Dim wrd As Object, inv As Word.Document, db As DAO.Database, rs As Recordset
        Set db = CurrentDb
    --->Set rs = db.OpenRecordset("Investigate", dbOpenSnapshot) 'debug says prob here
        MsgBox "TEST 1"
        Set wrd = New Word.Application
        MsgBox "TEST 2"
        Set inv = wrd.Documents.Open("j:\Investigation.doc")
        MsgBox "TEST 3"
        With inv.MailMerge
            .DataSource = rs
            .Destination = wdSendToPrinter
            MsgBox "TEST 4"
            .Execute
        End With
    b:  inv.Close
        Exit Sub
    
    a:  MsgBox Err.Description
        Resume b
    End Sub
    Attached Files Attached Files
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

Posting Permissions

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