Solved

open a existing excel workbook

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

756 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