Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default error on oXL.Workbooks.Open

I've made a form in VB6 and compiled an exe file. Clicking on the .ex
file opens the form, clicking on the button starts excel and opens
.xls file.
The code is:


Code
-------------------

Option Explicit



Private Sub Command1_Click()

Dim oXL As Excel.Application

Dim oWB As Excel.Workbook

Dim MyPath, MyName, MyFile As String



' Start Excel and get Application object.

Set oXL = CreateObject("Excel.Application")

oXL.Visible = True



' Get file



MyName = "\MySubFolder\MyXls.xls"

MyPath = App.Path

MyFile = MyPath & MyName

oXL.Workbooks.Open MyFile

oXL.Application.Visible = True



Exit Sub

Err_Handler:

MsgBox Err.Description, vbCritical, "Error: " & Err.Number



End Sub

-------------------



I get an error when excel is trying to open the .xls file (i'm sorry
can't describe the exact error, but i think it was something like
critical error in Myfile.exe caused .... in module <unknown at....).
the error occurs when the script is excecuting oxl.workbooks.open

This happened on two different machines running on windows98 an
office2000.

It works fine on my PC running on windows XP and office 2002 and on m
pc at work running on windows2000 and office 2002.

I've tried different codes for the line oxl.workbooks.open like:

oXL.Workbooks.Open (FileName:=MyFile)
oXL.Workbooks.Open ("C:\MySubFolder\MyXls.xls")
set oWB = oXL.Workbooks.Open(FileName:=MyFile)
set oWB = oXL.Workbooks.Open ("C:\MySubFolder\MyXls.xls")

None worked :(

Please help!

Thanks in advance!

Cheers,
Ari

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default error on oXL.Workbooks.Open

Hi arieribbens

MyPath = App.Path

I think this is your problem

Try

MyPath = oXL.DefaultFilePath

For the My Documents folder


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


"arieribbens " wrote in message ...
I've made a form in VB6 and compiled an exe file. Clicking on the .exe
file opens the form, clicking on the button starts excel and opens a
xls file.
The code is:


Code:
--------------------

Option Explicit



Private Sub Command1_Click()

Dim oXL As Excel.Application

Dim oWB As Excel.Workbook

Dim MyPath, MyName, MyFile As String



' Start Excel and get Application object.

Set oXL = CreateObject("Excel.Application")

oXL.Visible = True



' Get file



MyName = "\MySubFolder\MyXls.xls"

MyPath = App.Path

MyFile = MyPath & MyName

oXL.Workbooks.Open MyFile

oXL.Application.Visible = True



Exit Sub

Err_Handler:

MsgBox Err.Description, vbCritical, "Error: " & Err.Number



End Sub

--------------------



I get an error when excel is trying to open the .xls file (i'm sorry i
can't describe the exact error, but i think it was something like a
critical error in Myfile.exe caused .... in module <unknown at....).
the error occurs when the script is excecuting oxl.workbooks.open

This happened on two different machines running on windows98 and
office2000.

It works fine on my PC running on windows XP and office 2002 and on my
pc at work running on windows2000 and office 2002.

I've tried different codes for the line oxl.workbooks.open like:

oXL.Workbooks.Open (FileName:=MyFile)
oXL.Workbooks.Open ("C:\MySubFolder\MyXls.xls")
set oWB = oXL.Workbooks.Open(FileName:=MyFile)
set oWB = oXL.Workbooks.Open ("C:\MySubFolder\MyXls.xls")

None worked :(

Please help!

Thanks in advance!

Cheers,
Arie


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default error on oXL.Workbooks.Open

Could it be where you are installing and running the exe from. You do an
App.Path in the code, so this will point at that directory which could be
different on different machines, and then the sub-folder may not exit.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"arieribbens " wrote in message
...
I've made a form in VB6 and compiled an exe file. Clicking on the .exe
file opens the form, clicking on the button starts excel and opens a
xls file.
The code is:


Code:
--------------------

Option Explicit



Private Sub Command1_Click()

Dim oXL As Excel.Application

Dim oWB As Excel.Workbook

Dim MyPath, MyName, MyFile As String



' Start Excel and get Application object.

Set oXL = CreateObject("Excel.Application")

oXL.Visible = True



' Get file



MyName = "\MySubFolder\MyXls.xls"

MyPath = App.Path

MyFile = MyPath & MyName

oXL.Workbooks.Open MyFile

oXL.Application.Visible = True



Exit Sub

Err_Handler:

MsgBox Err.Description, vbCritical, "Error: " & Err.Number



End Sub

--------------------



I get an error when excel is trying to open the .xls file (i'm sorry i
can't describe the exact error, but i think it was something like a
critical error in Myfile.exe caused .... in module <unknown at....).
the error occurs when the script is excecuting oxl.workbooks.open

This happened on two different machines running on windows98 and
office2000.

It works fine on my PC running on windows XP and office 2002 and on my
pc at work running on windows2000 and office 2002.

I've tried different codes for the line oxl.workbooks.open like:

oXL.Workbooks.Open (FileName:=MyFile)
oXL.Workbooks.Open ("C:\MySubFolder\MyXls.xls")
set oWB = oXL.Workbooks.Open(FileName:=MyFile)
set oWB = oXL.Workbooks.Open ("C:\MySubFolder\MyXls.xls")

None worked :(

Please help!

Thanks in advance!

Cheers,
Arie


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default error on oXL.Workbooks.Open

hi guys..thanks for the replies...

MyPath = App.Path

I think this is your problem

Try

MyPath = oXL.DefaultFilePath

For the My Documents folder


This won't work as i have a setup which installs the .exe file and th
subfolder "MySubfolder" to the users Harddrive. So this could be an
location on the users HD.

This also means that:

Could it be where you are installing and running the exe from. You d
an
App.Path in the code, so this will point at that directory whic
could be
different on different machines, and then the sub-folder may no
exit.

shouldn't give me any problems.

I haven't managed to solve the problem so if anyone could give som
more help it would be very appreciated!

Cheers,
Ari

--
Message posted from http://www.ExcelForum.com

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
when i open an Excell file 3 workbooks open.Why? Iain40 Excel Discussion (Misc queries) 2 February 3rd 09 05:04 PM
EXCEL:Can't open any file without error saying it's ALREADY open??? Crackles McFarly Excel Worksheet Functions 1 November 1st 07 02:22 AM
When I open Excel, workbooks open automatically. How can I stop t Rhealbird Excel Discussion (Misc queries) 2 February 23rd 06 10:08 AM
Workbooks.Open closes other workbooks S. Daum Excel Programming 1 August 21st 03 07:47 PM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


All times are GMT +1. The time now is 08:43 PM.

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

About Us

"It's about Microsoft Excel"