Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default still having problem with open currently open excel file

I am still having trouble with the link to a already open excel workbook.
I am able to open/load a wookbook with the filename location. However I want
to be able to remove this and just have it use whatever the currently open
wookbook.

any hints?

John Coon

Dim ExcelApp As Excel.Application
Dim wbkObj As Workbook
Dim shtObj As Worksheet
On Error Resume Next
UserForm1.Hide
Err.Clear
Set ExcelApp = GetObject(, "Excel.Application")
If Err < 0 Then
Err.Clear
Set ExcelApp = CreateObject("Excel.Application")
If Err < 0 Then
MsgBox "Could Not Start Excel", vbExclamation
End
End If
End If
ExcelApp.Visible = True
Set wbkObj = ExcelApp.Workbooks.Open(Filename:="d:\vba\sample\p art4.xls")
Set shtObj = ExcelApp.Worksheets(1)
UserForm1.Show
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default still having problem with open currently open excel file

Try this

Set wbkObj = ExcelApp.ActiveWorkbook

--
Regards Ron de Bruin
http://www.rondebruin.nl


"John Coon" wrote in message ...
I am still having trouble with the link to a already open excel workbook.
I am able to open/load a wookbook with the filename location. However I want
to be able to remove this and just have it use whatever the currently open
wookbook.

any hints?

John Coon

Dim ExcelApp As Excel.Application
Dim wbkObj As Workbook
Dim shtObj As Worksheet
On Error Resume Next
UserForm1.Hide
Err.Clear
Set ExcelApp = GetObject(, "Excel.Application")
If Err < 0 Then
Err.Clear
Set ExcelApp = CreateObject("Excel.Application")
If Err < 0 Then
MsgBox "Could Not Start Excel", vbExclamation
End
End If
End If
ExcelApp.Visible = True
Set wbkObj = ExcelApp.Workbooks.Open(Filename:="d:\vba\sample\p art4.xls")
Set shtObj = ExcelApp.Worksheets(1)
UserForm1.Show
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default still having problem with open currently open excel file

Ron,

Thanks for your quick reply, I'll add your comments and see if that does the
trick!

John Coon
"Ron de Bruin" wrote in message
...
Try this

Set wbkObj = ExcelApp.ActiveWorkbook

--
Regards Ron de Bruin
http://www.rondebruin.nl


"John Coon" wrote in message

...
I am still having trouble with the link to a already open excel workbook.
I am able to open/load a wookbook with the filename location. However I

want
to be able to remove this and just have it use whatever the currently

open
wookbook.

any hints?

John Coon

Dim ExcelApp As Excel.Application
Dim wbkObj As Workbook
Dim shtObj As Worksheet
On Error Resume Next
UserForm1.Hide
Err.Clear
Set ExcelApp = GetObject(, "Excel.Application")
If Err < 0 Then
Err.Clear
Set ExcelApp = CreateObject("Excel.Application")
If Err < 0 Then
MsgBox "Could Not Start Excel", vbExclamation
End
End If
End If
ExcelApp.Visible = True
Set wbkObj =

ExcelApp.Workbooks.Open(Filename:="d:\vba\sample\p art4.xls")
Set shtObj = ExcelApp.Worksheets(1)
UserForm1.Show
End Sub






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
problem with open text file in excel 2007 Lina Excel Discussion (Misc queries) 8 September 18th 07 08:16 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
Open excel file problem Jason Zischke Excel Discussion (Misc queries) 11 August 24th 06 02:57 AM
Open email windows can't open, excel shreadsheet file .xls ? skiz Excel Discussion (Misc queries) 0 October 2nd 05 07:03 PM
How do I stop Excel from closing the open file each time I open a. Welsin Setting up and Configuration of Excel 3 January 8th 05 11:16 PM


All times are GMT +1. The time now is 07:20 PM.

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"