Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WORD MACROS Undocumented in VFP ?
Message
 
 
To
06/03/2001 09:36:40
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00481318
Message ID:
00482356
Views:
11
>>>>I am trying to write a VFP application in which I will be doing considerable creating of WORD DOCUMENTS. I can find help with basic concepts but nothing on more complicated structures. For example, the LIST structure is non-existent as far as I can tell. I have been searching everywhere and no-one seems to know anything. Is this just a forgotten area of documentation for VFP ?

PMFJI, but Word is a separate product from VFP. You don't expect Crystal Reports documentation to ship with VFP, why would you expect Word or other Office documentation to ship?

If you look in the Solutions samples, you will see some code that can get you started.

>>>See Microsoft Office Automation With VFP book at http://www.levelextreme.com/Live/partnership.asp
>>>
>>>You can also open a doc in Word, then record a macro under the Tools menu. Do what you need to do to the doc [e.g., do a search and replace]. Stop recording, go back the Macros under Tools, and Edit the macro. You will have code you can copy and paste into a VFP PRG. You will have to modify the code to VFP syntax.
>>
>>Well, the part about HAVE TO MODIFY THE CODE TO VFP syntax is the crux of my question. I know I can create a macro and use it as a guide. But getting it to the precise VFP code is the hard part. Without documentation it is pure guesswork.

From your comment below, I'm assuming you have the book. Pages 13-18 walk you through how to convert VBA to VFP. If you don't have the book available, you can also look at the following MS Knowledgebase article: http://support.microsoft.com/support/kb/articles/Q160/0/64.asp.

>Also, the book suggested above uses RANGE structures instead of SELECTION. Word macros always show SELECTION structures. Therefore, the book is almost useless.

The macro recorder doesn't always produce the best code for a task. The code it produces gives you an idea of what can be done, but there are often better ways to accomplish the same task. The Range vs. Selection objects is one of these cases.

Starting on page 44 is a discussion of the Selection object and the Range object. I urge you to read this (again, I'm assuming you have the book), as this is an important concept.

A Range is simply a contiguous area of the document (from a single insertion point to the entire document). You call the shots as to where that is, by referencing paragraphs, words, tables or other segments of the document. The Selection object is a special Range object, and is the point in the Application object where the user's cursor is, or contains the highlighted text. There can only be one Selection per Application, while there can be unlimited Ranges (because you reference them directly without relying on where the cursor is). Because the user can manipulate the Selection object (if the document is visible and there seems to be a nanosecond lull in the processing, you wouldn't believe what users can do!), it's not considered a "safe" way to do things. Additionally, the Selection seems to be a bit slower than using the Range.

If you don't have the book, you can reference the following pages for more information on Selection vs. Ranges, from the MSDN library:
http://msdn.microsoft.com/library/officedev/off2000/wohowWorkingWithRanges.htm
http://msdn.microsoft.com/library/officedev/off2000/wohowWorkingWithSelection.htm

HTH,
- della
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform