B
boswellgw
Group,
I am writing a macro in MS Word v.2002. I have open an Excel workbook
in which I want to place some data. Since the position of the data
varies, I want to place the data in the row where the cursor is
located. In an Excel macro I can determine the row
with the cursor as follows:
ThisRow=ActiveCell.Row
This code doesn't work in the Word macro. So I used the following
code:
Set BSParameters = GetObject("MODEL.xls")
BSParameters.Application.Visible = True
BSParameters.Parent.Windows(1).Visible = True
Set WorkingSheet = BSParameters.Worksheets("SUMMARY")
BSParameters.Worksheets("SUMMARY").Activate
ThisRow = BSParameters.Worksheets("SUMMARY").ActiveCell.Row
This also did not work. If I substitute this line:
ThisRow = BSParameters.Worksheets ("SUMMARY").Cells 4,1).Value. 'works
fine
the code functions as expected. However, if I use this line:
ThisRow = BSParameters.Worksheets("SUMMARY").ActiveCell.Value 'does
not work
The code doesn't work.
So there is some problem with using the "ActiveCell" function. Is
there an equivalent way to do this
in MS Word?
Regards,
Garry
I am writing a macro in MS Word v.2002. I have open an Excel workbook
in which I want to place some data. Since the position of the data
varies, I want to place the data in the row where the cursor is
located. In an Excel macro I can determine the row
with the cursor as follows:
ThisRow=ActiveCell.Row
This code doesn't work in the Word macro. So I used the following
code:
Set BSParameters = GetObject("MODEL.xls")
BSParameters.Application.Visible = True
BSParameters.Parent.Windows(1).Visible = True
Set WorkingSheet = BSParameters.Worksheets("SUMMARY")
BSParameters.Worksheets("SUMMARY").Activate
ThisRow = BSParameters.Worksheets("SUMMARY").ActiveCell.Row
This also did not work. If I substitute this line:
ThisRow = BSParameters.Worksheets ("SUMMARY").Cells 4,1).Value. 'works
fine
the code functions as expected. However, if I use this line:
ThisRow = BSParameters.Worksheets("SUMMARY").ActiveCell.Value 'does
not work
The code doesn't work.
So there is some problem with using the "ActiveCell" function. Is
there an equivalent way to do this
in MS Word?
Regards,
Garry