Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automating Access 2003 launching Word 2003 run Word Maco

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
In Access
I am on a particlat record, "a persons name" say "Smith"

I want to click a button in an Access form
open a word doc which has a large calendar with a peoples directory. launch the "find macro" passing the name "smith" to it which will then hightlight them in the directory so I can change their data.

Access VBAcode lanuches Word
Code:
    Dim WordAppLocation, DocName, Macroname As String
    Dim x As Object
    
    WordAppLocation = "C:\Program Files\Microsoft Office\Office11\WINWORD.EXE"
    DocName = "\\foc01\SharedDir\Calendar School\2011-2012\calendar 2011-2012-Final.doc"
    Macroname = "FindText"
    
    x = Shell(WordAppLocation & " " & DocName & "m/" & Macroname, vbMaximizedFocus)

Word macro finds text
Code:
Sub FindText(nameTofind)
    With Selection.Find
        .Text = "smith" 'nameTofind < be changed when it works
        '.Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
    End With
    Selection.Find.Execute
End Sub

how can I do this?
is there a way to pass command-line variables like you can with Access?

DougP
 
What about something like this (typed, untested)?
Code:
Dim DocName As String
Dim x As Object
DocName = "\\foc01\SharedDir\Calendar School\2011-2012\calendar 2011-2012-Final.doc"
Set x = GetObject(DocName)
With x.Application
  .Visible = True
  .Run "FindText", Me![person name]
End With

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,
two issues/questions
1. is error
Wrong number of arguments or invalid Property assignment.
on this line:
.Run "FindText", Me![person name]

2. do I need to launch Word or does your code take care of that?
such as shell
x = Shell(WordAppLocation ...
or
Dim oApp As Object
Set oApp = CreateObject("Word.Application")



DougP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top