Solved

VB & Excel

Posted on 1998-06-17
4
288 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Yronnen,

It worked fine,
Thanks for your help!


Baltaz13
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now