Solved

VB & Excel

Posted on 1998-06-17
4
292 Views
Last Modified: 2010-05-03
I am trying to do the following using excel OLE objects in VB:

* Open  a specific filename in excel from VB
* Open the file in readonly mode
* make excel with the workbook the active window
* make excel open maximised

I am sure there is an easy answer, but could not find the correct syntax do it

I would appreciate some help

Regards
Baltaz13
0
Comment
Question by:mmahdi
  • 2
4 Comments
 

Expert Comment

by:qizhizhu
ID: 1463540
Try "Shell" command. you need to activate ".exe" file first, then open your excel file from VB. The syntax should look like "Shell("c:\excel.exe","c:\excle.xls").
Also you can try "GetObject" or try to use active X control.

0
 
LVL 1

Author Comment

by:mmahdi
ID: 1463541
qizhizhu,

It is not the answer I had in mind. I am looking for the syntax for OLE automation with Excel such as:

Set obj= CreateObject("excel.APPLICATION.8")
obj.Workbooks.Open (excelfile)
.
.

Regards
Baltaz13
0
 
LVL 5

Accepted Solution

by:
yronnen earned 50 total points
ID: 1463542
This is what you should do:
In the VB IDE create a reference for Microsoft Excel 8 object lib.

This code will do what you've requested:
    Dim XL As New Excel.Application 'creates an excel object
    XL.Workbooks.Open "c:\my documents\work.xls", , True 'opens file in read only mode
    XL.Visible = True 'must be
    XL.WindowState = xlMaximized 'maximizes the window

0
 
LVL 1

Author Comment

by:mmahdi
ID: 1463543
Yronnen,

It worked fine,
Thanks for your help!


Baltaz13
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we 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…
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…

774 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