Is this code lilely to be OK in Vista/A2003 or Vista/A2007

  • Thread starter Thread starter Mike375
  • Start date Start date
M

Mike375

Guest
The following runs fine on A2003 and XP. As you can see it is about Access data into Word bookmarks. The last part of the code is opening a record in a Many table and pasting the Word.doc into a memo field. The rest of the data base is macro except for code I use in conjunction with Right() and Left() but I am not worried about that as it can be done in A2003/XP as it is data manipulation that is only done once a month or so.

The only difference to the code below and the "real thing" is the real thing simply has a lot more bookmarks involved.

Dim WordObj As Word.Application
Dim wordDoc As Word.Document
Dim WordRange As Word.Range
Set WordObj = CreateObject("Word.Application")
Set wordDoc = WordObj.Documents.Open _
("C:\Letters\0AMPMikeCopy.doc")
WordObj.Visible = True


Set WordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="name")

WordRange.InsertBefore [Forms]![PrintandClose]![FirstName] PrintandClose is the name of then form the code is run from and different versions are behind labels
Set WordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="business")

WordRange.InsertBefore [Forms]![PrintandClose]![Surname]

Set WordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="scroll3")

WordRange.InsertAfter [Forms]![PrintandClose]![Surname]

DoCmd.OpenForm "LHInsert1", acNormal, "", "", acEdit, acNormal
Set WordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="a4")

WordRange.InsertAfter [Forms]![LHInsert1]![Description]

DoCmd.Close acForm, "LHInsert1"

DoCmd.OpenForm "ProspectNotes", acNormal, "", "[NameNumber]=[Forms]![PrintandClose]![NameNumber]", acEdit, acNormal
Set WordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="pn")
WordRange.InsertAfter Nz([Forms]![ProspectNotes]![ActdateComments], "")
DoCmd.Close acForm, "ProspectNotes"

wordDoc.Bookmarks("Tester").Select
wordDoc.ActiveWindow.Selection.InsertBefore [Forms]![PrintandClose]![ALine] This is going into the footer of the letter

wordDoc.Range.Select
wordDoc.ActiveWindow.Selection.Copy



wordDoc.PrintOut

DoCmd.GoToRecord , "", acNext
DoCmd.Close acForm, "PrintandClose"

DoCmd.OpenForm "LetterStoreRecord", acNormal, "", "", acEdit, acNormal
DoCmd.GoToRecord , "", acNewRec

DoCmd.SelectObject acForm, "LetterStoreRecord", False
DoCmd.GoToControl "Letter"
DoCmd.DoMenuItem 0, 1, 3, 0, acMenuVer70 ' Form, Edit, Paste

DoCmd.DoMenuItem 0, 5, 4, 0, acMenuVer70 ' Form, Records, Save Record
DoCmd.OpenForm "PrintandClose", acNormal, "", "", acEdit, acNormal
Forms!PrintandClose.RecordSource = "GridJoinNamesSingle"
DoCmd.RunMacro "Macro11TimerSingle", , ""

Forms!LetterStoreRecord!Name = Forms![12ProspectT]![CL Surname]
Forms!LetterStoreRecord!NameNumber = Forms![12ProspectT]!NameNumber
Forms!LetterStoreRecord!Done = Now()

DoCmd.Close acForm, "LetterStoreRecord"

wordDoc.Close False
WordObj.Visible = False
 
Last edited:
are you asking if it is fine? My guess would be, YES. not too much difference in coding between 2003 and 2007.

Not sure about Vista, but I doubt it would interfere. (all print is suggestion based.) :)
 
Adam,

I am looking bring on another person they have one computer with Vista/A2003 and one with Vista/A2007

SendKeys is a problem with Vista but I can get around that OK.
 

Users who are viewing this thread

Back
Top Bottom