C
cjmillerFL
Hello,
I have a VBA that exports the data from a Word table into a Excel file. The
Visual Basic file that is run calls out the specific Excel (in this case
WISTL.xls") file to be opened and then the data imported into the Excel
spreadsheet. The issue I have is that my "Personal.xls" file opens and note
the WISTL.xls file (as I see called out in the code). Please see code below
(since I'm not a guru in Visual Basic and am having a difficult time
explaining this).
Any help would be appreciated. Thanks...
------------------------------------------------------------------------------------------------
Sub UpdtWatchItem()
Dim MyXL As Object
' Variable to hold reference
' to Microsoft Excel.
Dim ExcelWasNotRunning As Boolean
' Flag for final release.
On Error Resume Next
' Defer error trapping.
Set MyXL = GetObject(, "Excel.Application")
If Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear
' Clear Err object in case error occurred.
Set MyXL = GetObject("D:\Documents and Settings\millecj\Desktop\WIForm
Test\WISTL.xls")
MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True
MyXL.Application.ScreenUpdating = True
MyXL.activesheet.Range("A3").Select
Dim i As Integer
i = 3
For i = 3 To 200
If MyXL.activesheet.Range("a" & i) = "WI-" &
ActiveDocument.Bookmarks("WIyear").Range _
& "-" & ActiveDocument.Bookmarks("WInbr").Range Then
'If MyXL.activesheet.Range("a" & i) =
ActiveDocument.Bookmarks("WInbr").Range Then
GoTo Continue
End If
Next
I have a VBA that exports the data from a Word table into a Excel file. The
Visual Basic file that is run calls out the specific Excel (in this case
WISTL.xls") file to be opened and then the data imported into the Excel
spreadsheet. The issue I have is that my "Personal.xls" file opens and note
the WISTL.xls file (as I see called out in the code). Please see code below
(since I'm not a guru in Visual Basic and am having a difficult time
explaining this).
Any help would be appreciated. Thanks...
------------------------------------------------------------------------------------------------
Sub UpdtWatchItem()
Dim MyXL As Object
' Variable to hold reference
' to Microsoft Excel.
Dim ExcelWasNotRunning As Boolean
' Flag for final release.
On Error Resume Next
' Defer error trapping.
Set MyXL = GetObject(, "Excel.Application")
If Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear
' Clear Err object in case error occurred.
Set MyXL = GetObject("D:\Documents and Settings\millecj\Desktop\WIForm
Test\WISTL.xls")
MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True
MyXL.Application.ScreenUpdating = True
MyXL.activesheet.Range("A3").Select
Dim i As Integer
i = 3
For i = 3 To 200
If MyXL.activesheet.Range("a" & i) = "WI-" &
ActiveDocument.Bookmarks("WIyear").Range _
& "-" & ActiveDocument.Bookmarks("WInbr").Range Then
'If MyXL.activesheet.Range("a" & i) =
ActiveDocument.Bookmarks("WInbr").Range Then
GoTo Continue
End If
Next