General discussion

  • Creator
    Topic
  • #2079538

    Foxpro program generating Excel Forms

    Locked

    by ideafixer ·

    I need to write a FoxPro program that will generate different forms in Excel. Basically, the program will get some variables such as field names and lengths then it will publish the fields in Excel on a spreadsheet that can be saved to disk for dataentry. The column names will have to be locked so they cannot be changed. Any suggestions?

All Comments

  • Author
    Replies
    • #3787946

      Foxpro program generating Excel Forms

      by shais rosenblatt ·

      In reply to Foxpro program generating Excel Forms

      If you’re using Visual FoxPro, you can easily use Automation to control Excel.

      Here’s a code snippet to get you started:

      LOCAL lcErrorHandler, llErrorOccurred, ;
      loExcel, loThisSheet

      lcErrorHandler = ON(“ERROR”)
      llErrorOccurred = .F.
      ON ERROR llErrorOccurred = .T.
      loExcel = GETOBJECT(, “Excel.Application”)
      IF llErrorOccurred
      llErrorOccurred = .F.
      loExcel = CREATEOBJECT;
      (“Excel.Application”)
      ENDIF
      ON ERROR &lcErrorHandler
      loExcel.Visible = .T.
      loExcel.Workbooks.Add()
      loThisSheet = ;
      loExcel.ActiveWorkBook.ActiveSheet
      WITH loThisSheet
      .Name = “My Data Entry Form”
      .Range(“A1”).Value = “A Header”
      .Range(“A2”).Select
      ENDWITH
      loExcel.ActiveWindow.FreezePanes = .T.
      The VB for Excel help file should be a good reference to help you figure out how to do what you need . . .

    • #3775989

      Foxpro program generating Excel Forms

      by shaisr ·

      In reply to Foxpro program generating Excel Forms

      Hmmm. It looks like the formatting wasn’t saved. Maybe we can try that again:

      LOCAL lcErrorHandler, llErrorOccurred, ;
          loExcel, loThisSheet

      lcErrorHandler = ON(“ERROR”)
      llErrorOccurred = .F.
      ON ERROR llErrorOccurred = .T.
      loExcel = GETOBJECT(, “Excel.Application”)
      IF llErrorOccurred
          llErrorOccurred = .F.
          loExcel = CREATEOBJECT;
              (“Excel.Application”)
      ENDIF
      ON ERROR &lcErrorHandler
      loExcel.Visible = .T.
      loExcel.Workbooks.Add()
      loThisSheet = ;
          loExcel.ActiveWorkBook.ActiveSheet
      WITH loThisSheet
          .Name = “My Data Entry Form”
          .Range(“A1”).Value = “A Header”
          .Range(“A2”).Select
      ENDWITH
      loExcel.ActiveWindow.FreezePanes = .T.

      Hope this helps . . .

    • #3782412

      Foxpro program generating Excel Forms

      by ideafixer ·

      In reply to Foxpro program generating Excel Forms

      This question was closed by the author

Viewing 2 reply threads