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

x
?
Solved

VB & Excel

Posted on 1998-06-17
4
Medium Priority
?
301 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
[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
  • 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 150 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 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