Finding Microsoft office excel

Hi

I want to open an excell spreadsheet from Access 2003 using the Call shell(C:\Program Files etc etc. Problem some PC's have Program Files and Program Files(x86) depending 64 or 32 bit PC. My question how can I via VBA determine if a PC has Program Files or both Program Files and Program Files(x86). Any advice appreciated

chestera
chesteraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin SparksCommented:
Is there any reason to need the Shell command, rather than opening the sheet using the object method?

Kelvin
0
Rey Obrero (Capricorn1)Commented:
try

shell syscmd(9) & "excel.exe" & " " & <path to the excel file>



syscmd(9) is the equivalent of syscmd(acSysCmdAccessDir)

which will give you were the MsAccess.exe is as well as the "Excel.exe"
0
chesteraAuthor Commented:
Kevin

Thank you for the reply. No reason I have just used the shell command before

Alan
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

chesteraAuthor Commented:
Capricorn1

Can you see anything wrong with this because I keep getting file not found. I have the folder and file as stated. Sorry I didn't reply before I got confused to who sent what

Filename = "StockPriceList.xls"
Tpath = "C:\CiagentSpreadsheet\" & Filename
Shell SysCmd(9) & "excel.exe" & " " & Tpath

Alan
0
Kelvin SparksCommented:
You could try this. Is commonly used where you want in interact with Excel via VBA.

Dim objExcel As Object

Set objExcel = CreateObject("Excel.Application")
objExcel.Documents.Add sTFile
objExcel.Visible = True

Kelvin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kelvin SparksCommented:
sTFile would be the full file path and filename of the spreedsheet
0
chesteraAuthor Commented:
Kelvinsparks

Get the error message
Object doesn't support this property or methode

Alan
0
chesteraAuthor Commented:
kelvinsparks

Tried the Call Shell("C:\Program Files etc on my laptop (a 32 bit machine) and it works I think the File not Found on my PC (64 bit) refers to excel.exe

Alan
0
chesteraAuthor Commented:
Kelvinsparks

I have it now working using
Filename = "StockPriceList.xls"
Tpath = "C:\Users\Public\Dropbox\Data\" & Filename
Tpath = "C:\CiagentSpreadsheet\" & Filename
stAppName = "C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe" & " " & Tpath
Call Shell(stAppName, 1)

problem i didn't have a space Program Files(requires a space) (x86)
So back to my original question is there away of identifying 64bit and 32 bit PC

Alan
0
chesteraAuthor Commented:
kelvinsparks

Found a solution

Set objProc = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'")
Filename = "StockPriceList.xls"
Tpath = "C:\Users\Public\Dropbox\Data\" & Filename

If objProc.Architecture = 0 Then
    stAppName = "C:\Program Files\Microsoft Office\Office14\Excel.exe" & " " & Tpath

ElseIf objProc.Architecture = 9 Then
    stAppName = "C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe" & " " & Tpath

End If

Call Shell(stAppName, 1)

Detects if 64bit or 32bit

Alan
0
Rey Obrero (Capricorn1)Commented:
from the immediate window, type this and post back the returned string


?syscmd(9)



.
0
Kelvin SparksCommented:
Hi Alan

Firstly, the syscmd solution was offered by Capricorn1. He would be best to answer questions on the solution using that. I am not overly familiar with that approach.

Secondly, if Excel is 64 bit, is Access also 64 bit. It is quite a different beast and I have avoided it and never tried my code in that environment - but would have expected it to work - you said it didn't (errored) but did not give any details.

Kelvin
0
chesteraAuthor Commented:
kelvinsparks

I will get back to you.

Alan
0
chesteraAuthor Commented:
kelvinsparks

Kevin

Windows is 64bit (My PC) and office is 32 bit the app will go on some 64bit systems and 32bit systems.
Office on all systems is excel 2010 32bit

I typed in ?syscmd(9) but got object not supported

Alan
0
Rey Obrero (Capricorn1)Commented:
did you typed it in the Immediate window ?
0
chesteraAuthor Commented:
capricorn1
could you refresh my memory. Immediate window??.
Are you having trouble with EE when I tried to log in typing user name and password was very slow as is with scrolling up and down the page

Alan
0
Rey Obrero (Capricorn1)Commented:
the immediate window is the window below the code window

you can open it by from the menu View > Immediate Window

or by pressing Ctrl + G
0
chesteraAuthor Commented:
capricorn1

ctrl + G yes now I remember. Thank you

Alan
0
chesteraAuthor Commented:
capricorn1

I get
C:\Program Files (x86)\Microsoft Office\OFFICE11\
0
Rey Obrero (Capricorn1)Commented:
hmm, that is why you are getting the error,

 you have a different version of office for Access (2003) and Excel (2010)
0
chesteraAuthor Commented:
capricorn1

I am now using this it works

Set objProc = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'")
Filename = "StockPriceList.xls"
Tpath = "C:\Users\Public\Dropbox\Data\" & Filename

If objProc.Architecture = 0 Then
    stAppName = "C:\Program Files\Microsoft Office\Office14\Excel.exe" & " " & Tpath

ElseIf objProc.Architecture = 9 Then
    stAppName = "C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe" & " " & Tpath

End If

Call Shell(stAppName, 1)

Detects if 64bit or 32bit

If a 64bit system Program Files and Program Files (x86) folders are created. My PC is running 64bit system and 32bit office

How I see it the usual shell command
stAppName = "C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe" & " " & Tpath
Call Shell(stAppName, 1)

is looking for the Excel.exe in the Program Files folder.

If a system 64bit and Office 64.bit I don't think there would be a problem

What are your thoughts

Alan
0
Rey Obrero (Capricorn1)Commented:
ok.. glad you got it working.
0
chesteraAuthor Commented:
Thank your feed back most appreciated

Alan
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.