Automation can be tricky at the best of times and what starts out as a straight forward task becomes a total nightmare. You spend hours converting office macro code to VFP only to come up with an error telling you that eg. "Variable XLUNDERLINE not found".
This is where header files come in. If you look in most of the VFP books that are out they will give you examples of VFP automating Microft Office products but when you copy and paste the code it doesn't work. Unfortunitly header files are not included in the office packages BUT as it happens there is away around this problem.
Microsoft Visual Studio users can create header files using the Object viewer but what if you only have VFP?
As I'm sure you are aware, every office product ships with a .olb file which stores all the specific commands in that program. The following code extracts all the useful info out of the files and saves them as a .h file. Then all you have to do is include the file in forms or programs whenever you are automating office proucts.
****************START CODE****************
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.SHOW
RETURN
****************FORM CODE****************
DEFINE CLASS form1 AS FORM
lcConstantsStr = []
FOR EACH Obj IN oTLB_INFO.Constants
lcConstantsStr = lcConstantsStr + CRLF + "* " + Obj.Name + CRLF
FOR EACH member IN Obj.Members
lcConstantsStr = lcConstantsStr + [#DEFINE ] + ;
member.NAME + [ ] + ;
TRANSFORM(member.VALUE) + CRLF
NEXT member
NEXT Obj
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.