Solved

Work with Excel Spreadsheet from within Access

Posted on 2002-07-16
5
360 Views
Last Modified: 2008-02-26
I know how to export a query out to Excel in VBA.

After the spreadsheet is created, I want to programmatically do the following:

1)  Create a "Split" (panes) in the spreadsheet.  Coordinates would be at cell A4.

2)  Freeze the panes.

This would be the equivalent of choosing Window |Split in Excel, positioning the split to cell A4, then choosing Window | Freeze Panes.
0
Comment
Question by:knowlton
  • 3
5 Comments
 
LVL 5

Author Comment

by:knowlton
ID: 7158352
Even better, a few good web sites that have tutorials on this kind of thing, and the layout of the Excel object model.  Then I could help myself in the future.

Thanks!
0
 
LVL 3

Accepted Solution

by:
pbryan earned 50 total points
ID: 7158664
what I find easiest is to create a macro in excel, and then use that code in access...

In access you have to add a reference to the Excel application or in code use

set myexcel=createobject("Excel.application")

then all you usually have to do is add myexcel. infront of all you lines from the excel macro

----
have a look at http://www.mvps.org/dmcritchie/excel/excel.htm
0
 
LVL 12

Expert Comment

by:James Elliott
ID: 7159072
Something like this: (Make sure your excel library is referenced in your VB editor)

Dim xlapp As Object

Set xlapp = CreateObject("Excel.Application")

Workbooks("c:\BOOK1.XLS").Worksheets("Sheet1").Activate
With ActiveWindow
    .SplitColumn = 1
    .SplitRow = 2
    .Freezepanes = true
End With

Thanks

Jell

0
 
LVL 5

Author Comment

by:knowlton
ID: 7159888
I ended up creating the macro.
0
 
LVL 5

Author Comment

by:knowlton
ID: 7160691
   Dim objExcel As New Excel.Application

    objExcel.ActiveWorkbook.Save
   
    objExcel.Workbooks.Open strXLSName

    objExcel.Quit
   
     
    'DOES NOT CLOSE EXCEL!!!
    Set objExcel = Nothing
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

744 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