Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Word 97 Ole Automation Commands in Visual Fox
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00085204
Message ID:
00085396
Vues:
43
>Selection.Typetext text:="This is some bolded text"
>
>With the space, VFP's syntax checker gives a syntax error because of the space. Do you know how to handle situations like this, where you try to execute a VB method in VFP that has a space?
>

VBA and VB as a whole, supports named arguments. So, to convert the above,
you need to do this: oWord.Selection.TypeText("text here..."). VB does not allow you to use ()'s in methods if a return value is not present.

Make sure you have service pack 3 of Visual Studio installed as well as service pack 1 of Office. There were several issues regarding automation with Word that were fixed. In regards to your other needs, check out the macro recorder in word. That can give you clue as to the other objects and properties you will need to manipulate.

But... Here is an expanded version of the code to get you started...


#Define wdAlignParagraphCenter 1
#Define wdAlignParagraphLeft 0
#Define wdToggle 9999998

oWord = CreateObject("word.application")
oWord.Documents.Add
With oWord.Selection
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Bold = wdToggle
.Font.Size = 12
.TypeText("This is a nice big title")
.TypeParagraph
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Font.Size = 10
.Font.Bold = wdToggle
.TypeText("Now I am back typing regular text.")
EndWith

oword.visible = .t.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform