Solved

open a existing excel workbook

Posted on 2000-03-01
3
210 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 30 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…

752 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