Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

word selection.find error

Status
Not open for further replies.

Rowse

Technical User
Dec 20, 2002
62
GB
I'm using this code:

With oWordApp.Selection.Find
.Text = "<CurrentDate>"
With .Replacement
.Text = System.DateTime.Now.ToShortDateString()
End With
.Execute(Replace:=Word.WdReplace.wdReplaceAll)
End With

but get an error message of:

System.NullReferenceException: Object variable or With block variable not set.
at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at B3WebService.Service1.B3DocumentSvc1(String DocumentName, WS_Quote Quote, WS_RentalStream PaymentHeader, WS_RentalStreamRecord[] Payments, Entity Customer) in D:\Code\WebService\Dev\App_Code\Service1.asmx.vb:line 248


any ideas why? the error line is the execute.
 
I imagine that "oWordApp.Selection" isn't returning anything and therefore the Find class can't execute it's Execute method. Try checking to see if it isn't equal to Nothing before proceeding.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top