Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Office automation from Foxpro-need to insert symbol in w
Message
De
18/04/2005 12:46:55
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
17/04/2005 18:10:49
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 8
Database:
Visual FoxPro
Divers
Thread ID:
01005636
Message ID:
01005848
Vues:
22
This message has been marked as the solution to the initial question of the thread.
>Hi everyone:
>I'm trying to automate entry into a table in Word using a VFP project. I have no problem entering values into the correct cell in a table, but entering a symbol is giving me an error. I can either enter the symbol at the beginning of a range (in which the range is the word document), or if i try to be more specific, i get the following error:
>
> "ole dispatch exception code 0 from Microsoft Word: This method or property is not available because the object does not refer to simple range or selection..."
>
>BTW, i am using MS word 97. What i want to do is insert a symbol (an arrow pointing upwards) in a specific cell in a table. here is the code that puts the arrow at the beginning of the page:
>
> oRange.insertsymbol(-3923,"symbol",.t.)
>
>Remember, oRange is the entire document.
>
>When I try to put it into a table (namely oTable)), my code is as follows:
>
> oTable.Cell[2,6].range.insertsymbol(-3921,"symbol",.t.)
>
>I get the above error message when I use this code. Does anyone have any advice? BTW, I have found the book MS office Automation with Visual Foxpro to be a very handy reference for my coding. Unfortunately, it doesn't have an answer to this specific problem. Any suggestion would be greatly appreciated.
>
>TIA,
>
>Paul

Paul,
Use selection and collapse before inserting. ie:
#DEFINE wdCollapseStart	1	
#DEFINE wdCollapseEnd	0	
oWord = CreateObject('Word.Application')
With oWord
	.Documents.Add
	oTable = .ActiveDocument.tables.add(.ActiveDocument.Content,3,8)
	oTable.Cell(1,3).Select
	.Selection.Collapse(wdCollapseStart)
	.Selection.InsertSymbol(9675,'',.t. )
	.Selection.TypeText(' Yes'+Chr(13))
	.Selection.InsertSymbol(9675,'',.t. )
	.Selection.TypeText(' No'+Chr(13))
	.Selection.InsertSymbol(9675,'',.t. )
	.Selection.TypeText(' Maybe')
	oTable.Cell(2,6).Select
	.Selection.Collapse(wdCollapseStart)
	.Selection.InsertSymbol(-3921,"symbol",.t.)
	oTable.Cell(1,1).Select
	.Selection.Collapse(wdCollapseStart)
	.Visible = .t.
	.Activate
endwith
PS: This would do too:

oRange = oTable.Cell(2,6).Range
oRange.Collapse(wdCollapseStart)
oRange.InsertSymbol(-3921,"symbol",.t.)

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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform