[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] to export AFL formulas' names and associated code towards Excel or Word


  • Date: Thu, 24 Dec 2009 10:00:46 -0000
  • From: "Reinsley" <reinsley@xxxxxxxx>
  • Subject: [amibroker] to export AFL formulas' names and associated code towards Excel or Word

PureBytes Links

Trading Reference Links



Hi,


Does it exist a way to export AFL formulas' names and associated code and the layouts names and Charts' names loaded into AB, from AB to Word or Excel ?

In the same spirit, here what VBA does.

Below, the first EXCEL VBA procedure export all the WorkBook's macros code into Word.
The second macro list all the procedures' names and the modules' names into a new XL sheet.


I have got a VBA macro that export all AB formulas c:\amibroker\formula\custom\*.afl to Word. But nothing about exporting loaded formulas.


Best regards




'======================
Sub CopyToWord()

'Add reference "Microsoft Word X.0 Object Library")
'and "Microsoft Visual Basic For Applications Extensibility "

'L Longre

  Dim VBC As VBComponent, W As Word.Application
  Dim S As Word.Selection
  On Error Resume Next
  Set W = GetObject(Class:="Word.Application")
  On Error GoTo 0
  If W Is Nothing Then
    Set W = New Word.Application
    W.Visible = True
  End If
  W.ScreenUpdating = False
  On Error GoTo Fin
  W.Activate
  If W.Documents.Count = 0 Then W.Documents.Add
  Set S = W.ActiveWindow.Selection
  For Each VBC In ThisWorkbook.VBProject.VBComponents
    With VBC.CodeModule
      If .CountOfLines And .Name <> "CopieCodeVersWord" Then
        S.InsertAfter vbCrLf _
        & "==================================" & vbCrLf$ & _
        "Nom du module : " & VBC.Name & vbCrLf$ _
        & "==================================" & vbCrLf$ & _
          vbCrLf$ & .Lines(1, .CountOfLines) & vbCrLf$
      End If
    End With
  Next VBC
Fin:
  W.ScreenUpdating = True
End Sub


'-----------------------------------
Sub ListMacrosModule()

'add référence :   
'"Microsoft Visual Basic For Application Extensibility 5.3"

'michdenis

Dim Wbk As Workbook, Sh As Worksheet
Dim VBCodeMod As Object, Comp As Object, C As Object
Dim StartLine As Long, i As Long, ProcName As String

'Identifie le classeur source où sont les procédures
Set Wbk = Workbooks("VBAexemple2.XLS") 'ou ce que tu veux

'Détruit la feuille si elle existe déjà.
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("MesProcs").Delete
Application.DisplayAlerts = True

'Ajoute une feuille au projet où sera fait le listing
Set Sh = Wbk.Worksheets.Add
'Nomme la feuille
Sh.Name = "MesProcs"

i = 1
'Boucle sur toutes les modules du projet, incluant le formulaire.
For Each C In Wbk.VBProject.VBComponents
  Set Comp = C
  sds = C.Name
  Set VBCodeMod = Wbk.VBProject.VBComponents(C.Name).CodeModule

  With VBCodeMod
    StartLine = .CountOfDeclarationLines + 1
    Do Until StartLine >= .CountOfLines
      Sh.Cells(i, 1).Value = .ProcOfLine(StartLine, vbext_pk_Proc)
      StartLine = StartLine + .ProcCountLines(.ProcOfLine(StartLine, _
              vbext_pk_Proc), vbext_pk_Proc)
      Sh.Cells(i, 1).Offset(, 1).Value = .Name
      StartLine = StartLine + 1
      i = i + 1
    Loop
  End With
Next

Set VBCodeMod = Nothing: Set Comp = Nothing: Set C = Nothing
Set Wk = Nothing: Set Sh = Nothing
End Sub
'-----------------------------------




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/