Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting a VBA script to VFP

Status
Not open for further replies.

jmjmjm

Programmer
Jul 19, 2004
17
0
0
ES
I am trying to convert a VBA script into VFP.

There are no problems until I hace this instruction

theTable.Column(2).Format.TextAlignment = mmTextAlignmentRight

mmTextAlignmentRight is equal to 2, but when I write the
following instruction in VFP 7.0,

theTable.Column(2).Format.TextAlignment = 2

I get an error.

The same happens with

theTable.Column(2).Format.TextAlignment = "2"

mmTextAlignmentRight is defined as a value of an "enumeration"

Has any one experience in converting VBA scripts into VFP?

TIA


 
Are you talking about word automation here? this should work with numeric constants as your first try.

But mm does not sound like a word constant, they'd normally start with wd.

I'd say it's "theTable" giving you trouble, if that is part of some document, in VFP you need to define it first, eg theTable = oWord.ActiveDocument.Tables(2), and then can use it the way it's used in VBA.

VBA has some automatic objects VFP does not have, eg if in VBA you do some selection, you will have a Selection object, in VFP you need to set a variable to that selection.

All in all give hentzenwerke a chance, in you'll find a book about office automation with foxpro.

Bye, Olaf.
 
Thanks Olaf. In the end I found the problem. I had to use

#DEFINE mmTextAlignmentRight 2

now it seems to work.
 
Wll, glad you got it working. Makes me wonder, why theTable.Column(2).Format.TextAlignment = 2 gave you an error too, though. Because using a constant, at runtime you'll do nothing more or less then that, as the precompiler does exchange the constant with the value.

Bye, Olaf.
 
Jmjmjm,

Are you sure about this? It looks a bit odd.

You are saying that:

theTable.Column(2).Format.TextAlignment = mmTextAlignmentRight

gives an error. But if you do:

#DEFINE mmTextAlignmentRight 2

The error goes away. Is that right?

If so, all that you are doing is setting a compile-time value for mmTextAlignmentRight. You should have got the same result if you did this in the first place:

theTable.Column(2).Format.TextAlignment = 2

But you are saying that that also caused an error?

If that's the case, either there is something wrong with your analysis, or there is some other cause for the error.

By the way, it would be interesting to know what the original error message was.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
You write upper faster a new VFP code then converting any VBA script.

Whenever you are on that trail, rethink.

Excel and Access can only do what present memory allow to do you. VFP allows the disk space remaining.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top