The word macro below is supposed to open an access database. The database puts up a form which gets some user input and creates a text file with some addresses in it and then closes. Upon close of Access, control is supposed to return to Word, which is then supposed to insert an envelope for each address in the text file that was created with Access. The Access database opens fine and produces the text file (it does have addresses in it), but it looks like Word is just going ahead without waiting for Access to return. Word just inserts an envelope before Access does its processing. Any way to get Word to wait at the point it goes to Access for Access to get done before proceeding?
Thanks
Sub test()
Dim ad$(20)
Dim AccessApp As Object
Set AccessApp = CreateObject("access.application"
AccessApp.Visible = True
AccessApp.openCurrentDatabase "c:\temp\test.mdb"
Close 1
Open "c:\temp\test.txt" For Input As 1
Do While Not EOF(1)
Line Input #1, add$
ActiveDocument.Envelope.Insert ExtractAddress:=False, OmitReturnAddress _
:=True, PrintBarCode:=True, PrintFIMA:=True, Height:=InchesToPoints(4.13 _
), Width:=InchesToPoints(9.5), Address:=Add$, AutoText:= _
"ToolsCreateLabels3", ReturnAddress:="", ReturnAutoText:= _
"ToolsCreateLabels4", AddressFromLeft:=wdAutoPosition, AddressFromTop:= _
wdAutoPosition, ReturnAddressFromLeft:=wdAutoPosition, _
ReturnAddressFromTop:=wdAutoPosition, DefaultOrientation:=wdLeftLandscape _
, DefaultFaceUp:=True
Loop
End Sub
Thanks
Sub test()
Dim ad$(20)
Dim AccessApp As Object
Set AccessApp = CreateObject("access.application"
AccessApp.Visible = True
AccessApp.openCurrentDatabase "c:\temp\test.mdb"
Close 1
Open "c:\temp\test.txt" For Input As 1
Do While Not EOF(1)
Line Input #1, add$
ActiveDocument.Envelope.Insert ExtractAddress:=False, OmitReturnAddress _
:=True, PrintBarCode:=True, PrintFIMA:=True, Height:=InchesToPoints(4.13 _
), Width:=InchesToPoints(9.5), Address:=Add$, AutoText:= _
"ToolsCreateLabels3", ReturnAddress:="", ReturnAutoText:= _
"ToolsCreateLabels4", AddressFromLeft:=wdAutoPosition, AddressFromTop:= _
wdAutoPosition, ReturnAddressFromLeft:=wdAutoPosition, _
ReturnAddressFromTop:=wdAutoPosition, DefaultOrientation:=wdLeftLandscape _
, DefaultFaceUp:=True
Loop
End Sub