Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

open a existing excel workbook

Posted on 2000-03-01
3
Medium Priority
?
214 Views
Last Modified: 2012-05-04
I am trying to open a existing excel workbook. Inside of it contains 7 sheets and I require to change input the information into cells. Can anyone tell me how to do so????I have use "set wb = getobject("c:\sale.xls") " to open this workbook. It seems like I had open the workbook. However, what ever information I had try to put into the worksheet is not sucessful. Can anyone take me through this???? Thanks
0
Comment
Question by:c4mar
3 Comments
 

Expert Comment

by:woodsrr
ID: 2575128
Try this:

I have a form with just 1 command buttons. The button opens a excel document, prints the value from cell 1,1 and then changes the value of cell 1,1.  
When you are done with your excel object call the xlApp.Quit method and then set your xlApp object to nothing to free up the resource.

Dim xlApp As Object

Private Sub Command1_Click()
    Set xlApp = CreateObject("excel.application")
    xlApp.Visible = True
    xlApp.workbooks.Open "C:\My Documents\CarLoc.xls"
    Print xlApp.Cells(1, 1) ' Printing the value of cell 1,1
    xlApp.Cells(1, 1) = "New Text" ' Changing the value of cell 1,1
End Sub

0
 
LVL 1

Expert Comment

by:georgeman
ID: 2577987
One more thing.
If you need update cell in particulary sheet, you need activate this sheet before or use sheet name directly in Excel object:

xlApp.Worksheets("MySheet").Activate
xlApp.Cells(1, 1) = "New Text" ' Changing the value of cell 1,1

or

xlApp.Worksheets("MySheet").xlApp.Cells(1, 1) = "New Text" ' Changing the value of cell 1,1
0
 

Accepted Solution

by:
dalbello earned 90 total points
ID: 2601500
Try this
-------------------------------------------------
Sub test()
' declare the objects
Dim wb As Workbook
Dim s1 As Worksheet
Dim s2 As Worksheet
Dim s3 As Worksheet
' ... etc
' ... etc
' Set the objects
Set wb = GetObject("c:\sale.xls")
Set s1 = wb.Sheets("NameOfSheet1")
Set s2 = wb.Sheets("NameOfSheet2")
Set s3 = wb.Sheets("NameOfSheet3")
' ... etc
' ... etc
' Write text in cells A1 of s1, s2 and s3
s1.Cells(1, 1).Value = "TEST TEXT"
s2.Cells(1, 1).Value = "TEST TEXT"
s3.Cells(1, 1).Value = "TEST TEXT"
' ... etc
' ... etc
End Sub
----------------------------------------------------
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question