Results 1 to 8 of 8

Thread: form freezing up

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    27

    form freezing up

    I last touched this code a few months ago, and for some reason it no longer works. When I push a 'commandbutton' in Word it is suppose to extract data from Excel and insert it into Word. However now when i press the 'commandbutton' it appears it just freezes and no data is pressed. both files are in the correct place on my computer to call up.

    VB Code:
    1. Public Sub CommandButton1_Click()
    2. HideListBoxes
    3.  
    4. Dim oDoc As Word.Document
    5.  
    6. Set oDoc = Application.Documents("C:\wordfile.doc")
    7. Dim oExcel As Excel.Application, myWB As Excel.Workbook
    8.    
    9. Set oExcel = New Excel.Application
    10. Set myWB = oExcel.Workbooks.Open("C:\excelfile.xls")
    11.  
    12. Dim b As Integer
    13.  
    14. b = CInt(myWB.Sheets("Sheet1").Range("B20").Value)
    15.  
    16. For i = 20 To b
    17.     oDoc.Bookmarks("bookmark1").Range.Text = myWB.Sheets("Sheet1").Cells(i, 2)
    18.    
    19. Next i
    20.  
    21. Set myWB = Nothing
    22. End Sub

    VB Code:
    1. Private Sub HideListBoxes()
    2.  
    3. CommandButton1.Visible = False
    4. End Sub
    Last edited by Pegasus0990; Jan 19th, 2007 at 10:34 AM.

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