Results 1 to 2 of 2

Thread: VBA

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 1999
    Location
    High Wycombe, United Kingdom
    Posts
    13
    Does any one know how to integrate VBA into an application written in VB?



  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    If you are going against a particular file (for example:Your File.xls), then go to the menu TOOLS-REFERENCE.

    Code:
       Dim MyXL As Object
       Dim ExcelWasNotRunning As Boolean
       On Error Resume Next
       'If the application isn't running, an  error occurs
       
       Set MyXL = GetObject(, "Excel.Application")
       If Err.Number <> 0 Then ExcelWasNotRunning = True
       
       Err.Clear
       
       ' Set the object variable to reference the file you want to see.
       Set MyXL = GetObject("c:\Trash\sara.xls")
       
       ' Show Microsoft Excel through its Application property. Then
       ' show the actual window containing the file using the Windows
       ' collection of the MyXL object reference.
       MyXL.Application.Visible = True
       MyXL.Parent.Windows(1).Visible = True
       ' Do manipulations of your file here
       If ExcelWasNotRunning = True Then MyXL.Application.Quit
       Set MyXL = Nothing

    If you just want to create a new file, then you don't need to reference

    Code:
       Dim xlApp As Object
       Set xlApp = CreateObject("Excel.Application")
       xlApp.Visible = True
       xlApp.Visible = True
       xlApp.Quit
       Set xlApp = Nothing
    Code exactly the way you would in Excel, but place the "xlApp." infront

    [Edited by Nitro on 04-21-2000 at 11:10 PM]
    Chemically Formulated As:
    Dr. Nitro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width