Information générale
Catégorie:
Codage, syntaxe et commandes
>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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement