S
StephanieH
I have a macro that picks up information from Word and pastes it into Excel.
It then makes a couple additional changes and queues the user to review the
results with a mesg box. If everything is well, the user selects OK and the
macro continues with some additional changes. If not, the user selects
cancel and makes some changes manually.
This is my first attempt at toggling between Word and Excel so I have a
vague understanding of what's happening, but it seems that all of the actions
to be performed in Excel require "oXL." before the line of code. However,
when I get the message box, placing oXL. before the line of code gives me a
message of "Wrong number of arguments or invalid property assignment".
However without it, it goes back to Word to prompt. It runs fine after that,
but I can't review the information in Excel without switching back and forth.
How to do I execute the message box in Excel?
oXL.Workbooks("MyWorkbook.xls").Activate
oXL.Sheets("sheet1").Activate
oXL.ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, _
DisplayAsIcon:=False
oXL.Range("c1").Select
oXL.Sheets("sheet2").Activate
oXL.Range("A1").Select
oXL.ActiveCell.Value = MyWordName
oXL.Sheets("sheet1").Activate
ans = MsgBox("OK?", vbOKCancel)
If ans = 2 Then End
If ans = 1 Then
oXL.Visible = True
oXL.Workbooks("MyWorkbook.xls").Activate
oXL.Sheets("sheet1").Activate
oXL.Range("c1").Select
oXL.ActiveCell.Value = MyWordName
It then makes a couple additional changes and queues the user to review the
results with a mesg box. If everything is well, the user selects OK and the
macro continues with some additional changes. If not, the user selects
cancel and makes some changes manually.
This is my first attempt at toggling between Word and Excel so I have a
vague understanding of what's happening, but it seems that all of the actions
to be performed in Excel require "oXL." before the line of code. However,
when I get the message box, placing oXL. before the line of code gives me a
message of "Wrong number of arguments or invalid property assignment".
However without it, it goes back to Word to prompt. It runs fine after that,
but I can't review the information in Excel without switching back and forth.
How to do I execute the message box in Excel?
oXL.Workbooks("MyWorkbook.xls").Activate
oXL.Sheets("sheet1").Activate
oXL.ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, _
DisplayAsIcon:=False
oXL.Range("c1").Select
oXL.Sheets("sheet2").Activate
oXL.Range("A1").Select
oXL.ActiveCell.Value = MyWordName
oXL.Sheets("sheet1").Activate
ans = MsgBox("OK?", vbOKCancel)
If ans = 2 Then End
If ans = 1 Then
oXL.Visible = True
oXL.Workbooks("MyWorkbook.xls").Activate
oXL.Sheets("sheet1").Activate
oXL.Range("c1").Select
oXL.ActiveCell.Value = MyWordName