[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

Access 97 – Activating Word, Excel or Power Point Without Knowing Their FilePath

I have tried the following code but I get “File Not Found” error message if these Microsoft programs are not in filepath c:\Program Files\Microsoft Office\Office
(e.g. If User has upgraded from Office 97 to Office 2000)

Code Sample 1

Dim stAppName = “winword.exe c:\My Documents\myfile.doc”
Call Shell (stAppName,1)

Code Sample 2
Dim MyAppId
MyAppId = Shell(“winword.exe c:\My Documents\myfile.doc”,1)
AppActivate MyAppId

Do you have a code sample that will work regardless of where Excel, Word or Power Point .exe's are stored on a user's PC?
0
jazzman2
Asked:
jazzman2
  • 11
  • 10
  • 2
1 Solution
 
bruintjeCommented:
Hi, jazzman2

code above will work, if winword or any other is registered correclty on the pc
it will not work if the file myfile.doc or any other is not in my documents

so is the file there?and are the applications working correct?

HTH:O)Bruintje
0
 
jazzman2Author Commented:
Hi bruintje,

Yes all the Microsoft applications are working and myfile.doc is in folder c:\My Documents

jazzman2
0
 
BangerterCommented:
i use this type of call the open other programs:

Dim appExl As Excel.Application
Set appExl = New Excel.Application
appExl.Workbooks.Open "c:\Temp\MyFile.xls"

are you just trying to open Word or is there a file you want to have open up into Word?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
jazzman2Author Commented:
Hi Bangerter

I am trying to open a specific .doc file in Word, a specific .xls file in Excel and a specific .ppt file in Power Point.

I am also trying to open Excel only.

Jazzman2
0
 
bruintjeCommented:
Hi Jazzman2,

you say this is after upgrading, but is this now on a machine with two installations?
0
 
jazzman2Author Commented:
Hi bruintje,

Yes, the PC has both Office 97 and Office 2000

Jazzman2

0
 
bruintjeCommented:
Hi Jazzman2,
ok then i guess the problem something like this

since 2000 is now the leading version, last installed but it seems not correctly registered in the registry

if you try to run this on the commandline for the word 2000 exe does that help?

regsvr32 yourpath\winword.exe

:O)Bruintje
0
 
jazzman2Author Commented:
Hi bruintje,

Word, Excel, Power Point 2000 all run fine on the client's PC ... they are all registered correctly.

My problem is I can't get them to start up with the two code examples I submitted with my question.

Do you have any other code that will work?

Thanks
Jazzman2
0
 
bruintjeCommented:
HI Jazzman2,

Bangerter gave an example already how to start Excel, if you want otheres which are basically teh same say so and we'll come up with more

basically calling the apps like

Dim objApp as Object
Set objApp = CreateObject("App.Application")
objApp.Open ("Yourfile")
objApp.visible = true

will work for all of them

HTH:O)Bruintje
0
 
bruintjeCommented:
where App is Excel, Word etc...
0
 
jazzman2Author Commented:
Hi bruintje

I tried Bangerter's example and Access 97 gave me error message "User-defined type not defined"

I tried your example and Access 97 gave me error message "Object doesn't support this property or method"

Do you have any other suggestions?

Thanks
Jazzman2
0
 
BangerterCommented:
for mine you will need to set the reference to the excel object library.
0
 
bruintjeCommented:
Hi Jazzman2,

OK, so it looks like we got a registry problem

what about trying it two other ways just to make sure?

-first method
-in your access project in tools | references | add the excel object in your references
-then replace the code above

Dim objApp as Excel.Application
Set objApp = CreateObject("Excel.Application")
objApp.Open ("Yourfile")
objApp.visible = true < comes the error here?

-second method
-in your access project in tools | references | add the excel object in your references
-then replace the code above

Dim objApp as Excel.Application
Set objApp = CreateObject("Excel.Application.9")
objApp.Open ("Yourfile")
objApp.visible = true < comes the error here?

:O)Bruintje

0
 
jazzman2Author Commented:
Hi Bruintje,

I tried the following code after I added Microsoft Word 8.0 Object Library to my References

Dim objApp As Word.Application
    Set objApp = CreateObject("Word.Application")
    objApp.Open ("c:\My Documents\myfile.doc")
    objApp.Visible = True

Now I get error message "Method or data member not found" and my code halts on line objApp.Open

Jazzman2
0
 
bruintjeCommented:
OK, my fault

what about

Word
objApp.Documents.Open("c:\My Documents\myfile.doc")

Excel
objApp.Workbooks.Open("c:\My Documents\myfile.xls")

it's getting late
0
 
jazzman2Author Commented:
Hi Bruintje,

This worked but Word opens my file in a minimized window ... Is there a way to open Word in a Maximized Window like you can when you use the Shell function with ,1 after the filepath?

I still have to try your suggested code on my client's PC tomorrow to see if it works there.

Thanks
Jazzman2
0
 
jazzman2Author Commented:
Hi Bruintje,

I found a solution to Maximizing the Application.

I still have a problem with this code ...

Dim objApp As PowerPoint.Application
    Set objApp = CreateObject("PowerPoint.Application")
    objApp.Presentations.Open ("C:\My Documents\MyPresentation.ppt")
    objApp.Visible = True
    objApp.WindowState = ppWindowMaximized

I get this error message ... "Presentations (Unknown member):Invalid request. The PowerPoint Frame window does not exist."

Do you know why I'm getting this message?

Jazzman2
0
 
bruintjeCommented:
Hi Jazzman2,

seems like Powerpoint needs some extra care here

try to activate it so the window/frame becomes available.

Set objApp = CreateObject("PowerPoint.Application")
objApp.Activate

so the frame/window becomes available first

:O)Bruintje
0
 
jazzman2Author Commented:
Hi Bruintje,

The objApp.Activate solved the problem with Power Point ... Thank you.

I will test with my client this morning and let you know if everything works.

Thanks Again
Jazzman2
0
 
jazzman2Author Commented:
Hi Bruintje,

Sorry I didn't get back to you earlier but my client was not able to perform the tests today.

I will get back to you Thursday with the results.

Jazzman2
0
 
bruintjeCommented:
Hi Jazzman2,

It's OK got no time anyway

:O)Bruintje
0
 
jazzman2Author Commented:
Hi Bruintje,

The test went well with my client.

Thank you for all your help.

Please send me a comment and I will "Accept Comment As Answer" and close this question.

Thanks, once again.

Jazzman2
0
 
bruintjeCommented:
thanks Jazzman2, glad it worked out OK

i'll just recap it all here

Word
Dim objApp As Object
objApp.Documents.Open("c:\My Documents\myfile.doc")
'.....run the rest

Excel
Dim objApp As Object
objApp.Workbooks.Open("c:\My Documents\myfile.xls")
'.....run the rest

Powerpoint
Dim objApp As Object
Set objApp = CreateObject("PowerPoint.Application")
objApp.Activate
'.....run the rest

:O)Bruintje
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 11
  • 10
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now