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 / Modules / DAO / VBA / January 2007

Tip: Looking for answers? Try searching our database.

Run Word vba in Access module

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
greeknl - 13 Jan 2007 13:58 GMT
Hi,

I am new here, I have learned a lot from this forum and my thanks to all
repliers with thaeir great suggestions.

But I have a question, using office 2003:
I am writing a vba module in Access to create a word document with values
from a the database. Everything ok there. I now want to add in the word
document a checkbox and a field counting pages.
I have managed to create a line using:

Dim oApp As Object
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
With oApp
.Selection.InlineShapes.AddHorizontalLineStandard

and I was also able to change the properties of the line.
As said I want to create a a checkbox and a field.

when using these commands, which I used in word vba and check again using the
macro recording tool in word I get errors what am I doing wrong?
.Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormCheckBox
.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldNumPages

I do not want to use records in Access of do this via a Word template.

Thank you
John Nurick - 13 Jan 2007 17:22 GMT
You don't say what error you're getting, but I'll guess that Access VBA
is not recognising the Word constants wdFieldFormCheckbox and
wdFieldNumPages.

You need to either
-go to Tools|References in the VB Editor and add a reference to
Microsoft Word 11.0 Object Library,
or
-replace the constants with their literal values (e.g.
wdFieldFormCheckBox = 71).

I'd do the first; this means you'll also be able to declare
    Dim oApp As Word.Application
(this is called 'early binding') and get the Intellisense features of
the VBE working on the Word objects as well as the Access ones.

>Hi,
>
[quoted text clipped - 24 lines]
>
>Thank you

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
greeknl - 13 Jan 2007 17:44 GMT
THANKS

I already had done step 1.
I replaced the wd... statement with the value 71 and voila there it was.
I have been trying to find the list with those constants. Can you help me on
this? Is there a list of all wd.... values available?

I suppose this also works with the numpages field I want to put in the
document?

You have been a real help.
Also this forum is one of the best I found on the net.

Thanks again
Douglas J. Steele - 13 Jan 2007 20:25 GMT
Best way I know of is to go into the VB Editor in Word, and determine the
values in the Immediate window.

You can also go through the Object Browser while in Word (or from Access if
you have a reference set to Word).

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Is there a list of all wd.... values available?
greeknl - 13 Jan 2007 20:34 GMT
Me again

after a bit of intense searching I found the link for these constants
http://msdn2.microsoft.com/en-us/library/aa211923(office.11).aspx#

and john, thanks again
 
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.