Jump to content

[VB] modifying excel files through vb


Recommended Posts


Hi,

do you intend to use a standalone VB application to modify a excel file or do you want to use vba?

If you are using a VB Standalone Application does the System on which it runs has Excel installed? If so, you can use a OLE Connection to remote control excel to do what you want. A few months ago i've written such a thing but i have to look for it - i will then post a example what i've done.

Egon

Link to comment
Share on other sites

am using this, i think it will be enough for what i want to do, but i don't mind seeing more examples and/or different ways

Private Sub Command1_Click()
'On Error GoTo err
Dim objExcel
   Dim objWorkBook
   Set objExcel = CreateObject("EXCEL.APPLICATION")
   Set objWorkBook = objExcel.Workbooks.Open("C:\test.xls")
   For i = 1 To 20
       For j = 1 To 20
         objExcel.cells(i, j).Formula =  i & ":" & j
         Me.Caption = "Testing vb-excel - " &  i & ":" & j
       Next
   Next
   objWorkBook.SaveAs ("C:\test2.xls")
   objWorkBook.Close True
   Set objWorkBook = Nothing
   Set objExcel = Nothing
'    objExcel.quit
Exit Sub
err:
MsgBox "ohh nooo! :( look what happened : " & Error

End Sub

actually my purpose is to avoid designing a Crystal report, similar to excel files that are already done, so i thought about changing the excels directly

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...