Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2005

Tip: Looking for answers? Try searching our database.

Open Application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JethroUK - 22 Oct 2005 09:40 GMT
Anyone see why this wont work?:

   Dim oApp As Object

   Set oApp = GetObject("InviteToInduction.doc", "Word.Application")
   oApp.Visible = True

I  get 'classname not found' - Tried it without the class:

   Set oApp = GetObject("InviteToInduction.doc")

Get 'invalid syntax'

Filename is correct - Not using a path because the file is local (Tried it
with full path - still no go) - CreateObject works with new app
Brendan Reynolds - 22 Oct 2005 11:25 GMT
I haven't done a lot of Word automation, and none recently. However, the
help file says that the first, "pathname" argument must be the full path and
name of the document, so unless someone knows different I wouldn't expect
the file name alone to work. And I'd expect a reference to a Word document
to return a Word.Document object instead of a Word.Application document. The
following test code seems to bear this out ...

Public Sub TestGetObject()

   Dim objApp As Object
   Dim objDoc As Object

   Set objDoc = GetObject("c:\documents and settings\brendan reynolds\" & _
       "my documents\doc1.doc")
   Debug.Print objDoc.Name
   Set objApp = objDoc.Parent
   Debug.Print objApp.Name

   Set objDoc = Nothing
   Set objApp = Nothing

End Sub

Result in the Immediate window ...
testgetobject
Doc1.doc
Microsoft Word

Signature

Brendan Reynolds

> Anyone see why this wont work?:
>
[quoted text clipped - 11 lines]
> Filename is correct - Not using a path because the file is local (Tried it
> with full path - still no go) - CreateObject works with new app
JethroUK - 22 Oct 2005 13:12 GMT
i tried your code as is (except the path):

Private Sub Invite_Click()
   Dim objApp As Object
   Dim objDoc As Object

   Set objDoc = GetObject("u:\!Clait2006\CLAIT2006
database\Congratulations.doc")
   Debug.Print objDoc.Name
   Set objApp = objDoc.Parent
   Debug.Print objApp.Name

   Set objDoc = Nothing
   Set objApp = Nothing

End Sub

Nothing - No Error msg - No document - No Debug window

Tried it on 2 machines - nothing - I cant figure whats wrong - I'll check
the my installation - Many Thanks

>I haven't done a lot of Word automation, and none recently. However, the
>help file says that the first, "pathname" argument must be the full path
[quoted text clipped - 40 lines]
>> Filename is correct - Not using a path because the file is local (Tried
>> it with full path - still no go) - CreateObject works with new app
Brendan Reynolds - 22 Oct 2005 21:09 GMT
The code isn't intended to display a document, only to demonstrate that
GetObject(full path/name of Word document) returns a Word.Document object,
not a Word.Application object, and that you can retrieve the Application
object using the Parent property of the Document object. So 'no error
message' and 'no document' are both as expected.

The Debug window and the Immediate window are the same window. The code was
designed to be executed from the Immediate window. You must have executed it
some other way, as I see you have changed my original procedure
declaration - you've changed 'Public' to 'Private'. You'll need to change it
back to Public to execute the code from the Immediate window, and ensure
that you have pasted the code into a standard module, not a class module
(this includes form and report modules). Alternatively, modify the code to
display message boxes instead of writing to the Debug/Immediate window ...

Public Sub TestGetObject()

   Dim objApp As Object
   Dim objDoc As Object

   Set objDoc = GetObject("u:\!Clait2006\CLAIT2006
database\Congratulations.doc")
   MsgBox objDoc.Name
   Set objApp = objDoc.Parent
   MsgBox objApp.Name

   Set objDoc = Nothing
   Set objApp = Nothing

End Sub
Signature

Brendan Reynolds

>i tried your code as is (except the path):
>
[quoted text clipped - 62 lines]
>>> Filename is correct - Not using a path because the file is local (Tried
>>> it with full path - still no go) - CreateObject works with new app
JethroUK© - 22 Oct 2005 23:24 GMT
i've never used debug window - i dont do much programming - but it works now
thanks - my original error was in:

objDoc.Visible = True

i was getting an error - i took the line out and couldn't see anything, when
i really only needed to put :

objDoc.Application.Visible = True

bit disappointed about having to put the absolute path when a relative path
would make it more portable (i'm working on several machines) oh hum - glad
it's sorted, i've planned about 5-6 mail-merges out of the database so i was
a bit concerned - thanks again

> The code isn't intended to display a document, only to demonstrate that
> GetObject(full path/name of Word document) returns a Word.Document object,
[quoted text clipped - 98 lines]
> >>> Filename is correct - Not using a path because the file is local (Tried
> >>> it with full path - still no go) - CreateObject works with new app
Jeff Boyce - 22 Oct 2005 13:33 GMT
You didn't mention which version(s) of Access and Word you are using.

When I began running into issues opening Word documents from within Access,
I ended up using the hyperlink to method to open the document.  That's been
working so far...

Regards

Jeff Boyce
<Office/Access MVP>

> Anyone see why this wont work?:
>
[quoted text clipped - 11 lines]
> Filename is correct - Not using a path because the file is local (Tried it
> with full path - still no go) - CreateObject works with new app
JethroUK© - 22 Oct 2005 17:03 GMT
i have office 2002 - i might try the hyperlink method - thanx

> You didn't mention which version(s) of Access and Word you are using.
>
[quoted text clipped - 22 lines]
> > Filename is correct - Not using a path because the file is local (Tried it
> > with full path - still no go) - CreateObject works with new app
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.