Pegasus0990
Technical User
i have not touched this code in a couple of months, but now i am on a different computer. when i use to push the 'command button' all the data i was trying to get from excel was passed to word. however now, when the 'command button' is pushed, it just accepts getting pushed, then freezes. i can tell that values are being passed to the Word VB by using 'watches.' however, nothing is outputted into the Word file, and the form doesnt dissapear.
i have the following referenced.
VB for apps
word 11.0 object library
excel 11.0 object library
office 11.0 object library
forms 2.0 object library
ole automation
normal
//the following code is in my Word BF//
Public Sub CommandButton1_Click()
HideListBoxes
Dim oDoc As Word.Document
Set oDoc = Application.Documents("C:\wordfile.doc")
Dim oExcel As Excel.Application, myWB As Excel.Workbook
Set oExcel = New Excel.Application
Set myWB = oExcel.Workbooks.Open("C:\excelfile.xls")
Dim b As Integer
b = CInt(myWB.Sheets("Sheet1").Range("B20").Value)
For i = 20 To b
oDoc.Bookmarks("bookmark1").Range.Text = myWB.Sheets("Sheet1").Cells(i, 2)
Next i
Set myWB = Nothing
End Sub
Private Sub HideListBoxes()
CommandButton1.Visible = False
End Sub
i have the following referenced.
VB for apps
word 11.0 object library
excel 11.0 object library
office 11.0 object library
forms 2.0 object library
ole automation
normal
//the following code is in my Word BF//
Public Sub CommandButton1_Click()
HideListBoxes
Dim oDoc As Word.Document
Set oDoc = Application.Documents("C:\wordfile.doc")
Dim oExcel As Excel.Application, myWB As Excel.Workbook
Set oExcel = New Excel.Application
Set myWB = oExcel.Workbooks.Open("C:\excelfile.xls")
Dim b As Integer
b = CInt(myWB.Sheets("Sheet1").Range("B20").Value)
For i = 20 To b
oDoc.Bookmarks("bookmark1").Range.Text = myWB.Sheets("Sheet1").Cells(i, 2)
Next i
Set myWB = Nothing
End Sub
Private Sub HideListBoxes()
CommandButton1.Visible = False
End Sub