Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

open a existing excel workbook

Posted on 2000-03-01
3
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 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