Solved

VB & Excel

Posted on 1998-06-17
4
299 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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses
Course of the Month6 days, 21 hours left to enroll

623 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