Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Open excel and workbook with VB6

How can I open a given spreadsheet on a specific worksheet using vb6 code?

Thanks!

Kevin
================
I'm doing this:
Dim oBook As Object
Dim oSheet As Object

If FindWindow("XLMAIN", vbNullString) Then
Set gbl_oExcel = GetObject(, "Excel.Application")
Else
Set gbl_oExcel = CreateObject("Excel.Application")
End If

Set oBook = GetObject(Me.txtSelectedSpreadsheet) '(this is my selected
spreadsheet)
Set oSheet = oBook.Worksheets("Parameters")

What syntax after this will make the spreadsheet and "Parameters" worksheet
visible?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 233
Default Open excel and workbook with VB6

Kevin,

do not forget:

to set the oExcel.visible = TRue to show excel when it was not running.


Also, when you want excel visible and fully working I would not suggest
automation, but a simple shell:

shell(Me.txtSelectedSpreadsheet)

Excel visibility will be the least of your worries when you want a
fully functional excel(on the other hand, if you don't want that,
automation gives you greater control)

After excel is running, use

Set oBook = GetObject(Me.txtSelectedSpread*sheet) '(this will select
the spreadhseet) Note that you can always skip GetObject(,
"Excel.Application") if you want a spreadsheet, since this will launch
excel if it is not running, and else connect to a running excel. If
your file is already open it will connect to that excel instance that
has your wb open

Set gbl_oExcel = oBook.Parent
Set oSheet =oBook.Sheets("Parameters")

or

Dm Unseen

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Open excel and workbook with VB6

Thanks DM Unseen. I'll give this a try today!

Kevin
"DM Unseen" wrote in message
oups.com...
Kevin,

do not forget:

to set the oExcel.visible = TRue to show excel when it was not running.


Also, when you want excel visible and fully working I would not suggest
automation, but a simple shell:

shell(Me.txtSelectedSpreadsheet)

Excel visibility will be the least of your worries when you want a
fully functional excel(on the other hand, if you don't want that,
automation gives you greater control)

After excel is running, use

Set oBook = GetObject(Me.txtSelectedSpread*sheet) '(this will select
the spreadhseet) Note that you can always skip GetObject(,
"Excel.Application") if you want a spreadsheet, since this will launch
excel if it is not running, and else connect to a running excel. If
your file is already open it will connect to that excel instance that
has your wb open

Set gbl_oExcel = oBook.Parent
Set oSheet =oBook.Sheets("Parameters")

or

Dm Unseen


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
Opening Excel, Book1 opens, remains open with other workbook open DanieB Excel Discussion (Misc queries) 0 September 3rd 09 08:23 AM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
Excel workbook does not open in open window on desktop DeanH Excel Discussion (Misc queries) 2 March 8th 05 09:51 AM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM


All times are GMT +1. The time now is 04:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"