Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I convert VB macros to VFP
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00550965
Message ID:
00551056
Views:
25
This message has been marked as the solution to the initial question of the thread.
>Hi All
>
>Is there a set of rules anywhere that define how to convert xl (VB ) macro code to vfp - The following is a snippet of the macro generated by XL. I have already created my loXL object.
>
>with loXl
>
> .ActiveSheet.Shapes.AddLabel(msoTextOrientationHorizontal, 11.25, -2.25, 0# , 0#).Select
> .Selection.ShapeRange(1).TextFrame.AutoSize = msoTrue
> .Selection.Characters.Text = ;
> "MOAT TRUCK SALES" + Chr(10) + "LINK 56" + Chr(10) + "ZONE 3" + Chr(10) + "WEIGHBRIDGE ROAD, DEESIDE IND. PARK" + Chr(10) + "CH52LL"
> With loXl.Selection.Characters(Start:=1, Length:=17).Font
> .Name = "Arial"
> .FontStyle = "Bold"
> .Size = 12
> .Strikethrough = False
> .Superscript = False
> .Subscript = False
> .OutlineFont = False
> .Shadow = False
> .Underline = xlUnderlineStyleNone
> .ColorIndex = xlAutomatic
> EndWith
>
>endwith
>
>Virtually all the lines except the 3rd fail, unrecognised command. I have included the excel.h file and defined the two mso variables. I have also replace the underscores with ; and the & with the + sign.
>
>Any help would be appreciated
>Thanks
>Derek

I kept pondering on this, the other problem is that the constants that start with "mso" are in the office constants and not in Excel's. The following piece should work for you: (just replace your excel.h constants file)
#include "d:\temp\xl97cons.h"
#Define msoTextOrientationHorizontal 1
#Define msoTrue .T.
loXL = Create("Excel.Application")
loXL.Workbooks.Open("D:\Temp\ExcelTest.xls")

with loXl
    .ActiveSheet.Shapes.AddLabel(msoTextOrientationHorizontal, 11.25, -2.25, 0 , 0).Select
    .Selection.ShapeRange(1).TextFrame.AutoSize = msoTrue
    .Selection.Characters.Text = ;
        "MOAT TRUCK SALES" + Chr(10) + "LINK 56" + Chr(10) + "ZONE 3" + Chr(10) + "WEIGHBRIDGE ROAD, DEESIDE IND. PARK" + Chr(10) + "CH52LL"
    With loXl.Selection.Characters(1, 17).Font
        .Name = "Arial"
        .FontStyle = "Bold"
        .Size = 12
        .Strikethrough = .f.
        .Superscript = .f.
        .Subscript = .f.
        .OutlineFont = .f.
        .Shadow = .f.
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    EndWith

endwith
loXL.Visible = .t.
Release loXL
HTH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform