Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Automation
Message
From
23/07/1999 04:07:46
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
22/07/1999 17:24:32
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00242018
Message ID:
00245202
Views:
21
>Sorry about that, it kept saying that i'd already posted that message and would'nt let me add to it....... Your suggestion worked great, I was also able to find weak add'l info on MSDN. A newly discovered tip for those trying automation is when you create the macro in word to import into Foxpro just use the arguments, strip out the word keywords ie. Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= "MACROBUTTON NoMacro [Insert your text here]", PreserveFormatting:=False would be passed as:
> Selection.Fields.Add ('.Selection.Range, wdFieldEmpty, "MACROBUTTON NoMacro [Insert your text here]", .f.') to pass a field object. Good luck and thanks again Cetin for the push down the proper path ;^)

Chas,
Did you try this. To me it seems it wouldn't work (didn't try). The correct syntax should be :
with oWord
.Application.Selection.Fields.Add(.Application.Selection.Range, ;
  wdFieldEmpty, "MACROBUTTON NoMacro [Insert your text here]", .f.)
Macro recording to get syntax is great. But you should keep in mind VFP uses positional arguments not named arguments. ie: Macro recorded :

ActiveDocument.SaveAs FileName := "c:\temp\test.doc", FileFormat := wdFormatRTF, Password := "hello", WritePassword := .t.

Translates as :
.ActiveDocument.SaveAs("c:\temp\test.doc", wdFormatRTF, , "hello", ,.t.)

Note that in VFP syntax optional arguments are omitted with an extra comma. The rest of the arguments are optional.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform