PDA

View Full Version : Excel Opening The Wrong File



MWE
01-19-2015, 07:15 AM
I am (still) running xl2003 and WinXP. Applications that have been running without problems for years are suddenly failing.

In many applications, I open an Excel file using VBA from another MS Office program (Word, Outlook, etc) using trypically


Dim xlappl As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlbookname As String

xlbookname = "D:\SomeDir\SomeFileName.xls"

Set xlappl = CreateObject("Excel.Application")
Set xlbook = xlappl.Workbooks.Open (xlbookname, UpdateLinks = False)


Regardless of what file I try to open, xlbook is set to Personal.xls

Any thoughts?

Aflatoon
01-19-2015, 07:24 AM
Are you sure that's the only workbook being opened? If so, is there any code in the Workbook_Open event of your personal macro workbook?

SamT
01-19-2015, 07:39 AM
Do you mean that personal.xls is the only file open (Workbooks.Count = 1)

OR

Do you mean that xlbook.Name = "Personal.xls"

Paul_Hossler
01-19-2015, 08:41 AM
Any chance that "D:\SomeDir\SomeFileName.xls" was saved as Hidden or Mininized?

Can you open "D:\SomeDir\SomeFileName.xls" using just Excel?

"Wrong File" or "Not the Right File"? Personal.xlsm in XLSTART is normally opened but hidden

snb
01-19-2015, 08:58 AM
What about


Sub M_snb()
GetObject("D:\SomeDir\SomeFileName.xls").Windows(1).Visible = True
End Sub

MWE
01-19-2015, 04:28 PM
Are you sure that's the only workbook being opened? If so, is there any code in the Workbook_Open event of your personal macro workbook?
There is no code in the Workbook_Open event of Personal.xls

MWE
01-19-2015, 04:29 PM
Do you mean that personal.xls is the only file open (Workbooks.Count = 1)

OR

Do you mean that xlbook.Name = "Personal.xls"
The latter, i.e., xlbook.Name = "Personal.xls"

MWE
01-19-2015, 04:32 PM
Any chance that "D:\SomeDir\SomeFileName.xls" was saved as Hidden or Mininized?

Can you open "D:\SomeDir\SomeFileName.xls" using just Excel?

"Wrong File" or "Not the Right File"? Personal.xlsm in XLSTART is normally opened but hidden
I have been testing this for several days. "D:\SomeDir\SomeFileName.xls" was not saved as hidden or minimized, etc.
Yes, the file opens fine using just Excel and the files opens fine when opened from another open workbook. It is just when a non-Excel application tries to open any Excel file
I am running xl2003, so the personal macro file is Personal.xls, not Personal.xlsm

GTO
01-19-2015, 09:09 PM
Could you post a word doc with the code necessary to replicate the issue? Do you happen to have an 'On Error Resume Next' someplace before the snippet you posted in #1?

Mark

snb
01-20-2015, 12:30 AM
Did you test my suggestion as a macro in Word ?

SamT
01-20-2015, 08:32 AM
It is just when a non-Excel application tries to open any Excel fileTo be specific. Does this happen when all other applications you have that currently can open excel, do open Excel?