Word

Imy South

Registered User.
Local time
Today, 02:14
Joined
Jul 5, 2004
Messages
15
:confused: Hi,

Does anyone know how to open a saved word document on a form????

Cheers
Imy :)
 
Ole Control or Browser?

You could put an ole control on your form (the xyz cactus tool), and name it oleWord.

Then put the following code on e.g. a command button

Code:
    Me.oleWord.Class = "Word.Document"
    Me.oleWord.SourceDoc = "c:\documents\example.doc"
    Me.oleWord.Action = acOLECreateLink

You could also put a browser control on your form (Insert, ActiveX Control... Microsoft Web Browser), name it WebBrowser and put code similar to this on your command button:

Code:
    Me.webBrowser.Navigate "c:\documents\example.doc"
 
Last edited:
Thanks, but

Thanks Adam,

I am a new user of access forms, could please guide me on how I would do the above please....

imy :)
 
Imy South said:
could please guide me on how I would do the above please....

After reading his reply it would seem that he has already told you how to di it.

Select the OLE tool from the toolbox, put it on your form, and then use the code given in the Click event of a command button. (selecting Code Builder)
 
I have tried it but its given me compile error: method or data member not found where .Class = is highlighted.... Any advise???? :)
 
Web Browser Cactus Tool?

If you inserted an ActiveX webBrowser control, but tried to use code for an OLE object, that might explain the problem.

But maybe using a webBrowser would be easier. A browser might not be quite as fast as an OLE, but there's only one line of code.

To insert an ActiveX Control, call down the Insert menu, choose ActiveX Control..., tap M twice, and look out for "Microsoft Web Browser". Select "Microsoft Web Browser", then click OK.

Find out what the new web-browser control is called: Right Click, Properties should tell you.

Then put this code on a button:

Code:
Me.What_The_Web_Browser_Is_Called.Navigate "c:\a_folder\a_document.doc"
 
Thank you

Thanks Adam.

The code in the web browser works. But what I would like is to be able do is press a button and then that opens a template that I have saved on desktop in MS Word. You explained the way to do it in web browser perfectly is there any chance you can show me on how to do it through a button? Thank you, your help is very much appreciated.


Imy :)
 
Code on the Button

If you put a button onto your form and call it "cmdTemplate",

(View, Toolbox; turn the Wizards off [the magic wand button at the top of the toolbox should be un-pressed]; draw a command button; then right click, Properties; turn to the "Other" tab, and type "cmdTemplate" against "Name".)

you could then put some code on it.

(Right click on the button, and, from the popup menu, choose Build Event...; choose "Code Builder" in the popup that now appears. You'll be taken to the VB code editor window.)

Make the code look like this:

Code:
Private Sub cmdTemplate_Click()

    Me.What_The_Web_Browser_Is_Called.Navigate "c:\documents\template.dot"

End Sub

I'm not sure if this will do exactly what you're wanting to do though. I'm guessing you want to open a new Word document based on your template and display this so your user can fill it out. The code above will I think open the template itself, rather than a new document based upon it.

Opening a new document based on a template is a whole other can of worms, and it might easier to approach this using OLE methods.
 
The active X browser control works well for something I am currently trying to do. I would like, if possible, to open the word file in the browser - but at 75% of the actual size. This will allow me to see the entire width of the document without having to scroll.

Does anyone know how to achieve this ?
 

Users who are viewing this thread

Back
Top Bottom