Hi All,
I should disclaim that I'm quite novice at this, so my approach to writing macros is to record individual steps to determine the appropriate method, then copy and paste.
In any event, I have a macro that creates a word doc from content in an excel file. I copied over the code for inserting a text field from the Word Macro Recorder:
And pasted it in my Excel project (with msWord):
When I attempt to run this I get a "wrong number of arguments or invalid property assignment" error at the line that attempts to add the text field. Is this because of a discrepancy in syntax between Word and Excel, or am I making some other mistake?
Any help you can provide would be great. Thanks in advance!
I should disclaim that I'm quite novice at this, so my approach to writing macros is to record individual steps to determine the appropriate method, then copy and paste.
In any event, I have a macro that creates a word doc from content in an excel file. I copied over the code for inserting a text field from the Word Macro Recorder:
Code:
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
And pasted it in my Excel project (with msWord):
Code:
With msWord
.Selection.TypeParagraph
.Selection.InsertDateTime DateTimeFormat:="M/d/yyyy", InsertAsField:=False, _
DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText Text:="Dear "
.Selection.FormFields.Add Range:=Selection.Range, Type:= _ wdFieldFormTextInput
.Selection.TypeParagraph
End With
When I attempt to run this I get a "wrong number of arguments or invalid property assignment" error at the line that attempts to add the text field. Is this because of a discrepancy in syntax between Word and Excel, or am I making some other mistake?
Any help you can provide would be great. Thanks in advance!