dbTalk Databases Forums  

mail merge by Albert D. Kallal new problem

comp.databases.ms-access comp.databases.ms-access


Discuss mail merge by Albert D. Kallal new problem in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sparks
 
Posts: n/a

Default mail merge by Albert D. Kallal new problem - 11-09-2011 , 08:24 AM






I have had this set up and working for a long time.
perfect until now.
I am assuming a microsoft update of some kind.

Set WordDoc = wordApp.Documents.Open(strDocName)

this now says there is no object


wordApp.ActiveDocument.Name
here it says command not available because no document is open
but it is in the task manager.

I can only assume that I can not longer do anything with the open word
document.

is there any way to modify this to use the open word document?
made sure I still have dao 3.6 in references
visual basic for applications
microsoft access 11.0 object library
ole automation
microsoft activX data objects 2.1 library
microsoft word 11.0 object library
the default was 12.0 but I loaded this to see if it made any
difference...it didn't

Reply With Quote
  #2  
Old   
Bob Barrows
 
Posts: n/a

Default Re: mail merge by Albert D. Kallal new problem - 11-09-2011 , 08:38 AM






sparks wrote:
Quote:
I have had this set up and working for a long time.
perfect until now.
I am assuming a microsoft update of some kind.

Set WordDoc = wordApp.Documents.Open(strDocName)

this now says there is no object

Where is wordApp defined and opened? That's the part that must be broken.

Reply With Quote
  #3  
Old   
sparks
 
Posts: n/a

Default Re: mail merge by Albert D. Kallal new problem - 11-09-2011 , 09:45 AM



Function RidesMergeWord(strDocName As String, strDataDir As String,
adrastring As String)


Debug.Print strDataDir

Dim wordApp As Word.Application
Dim WordDoc As Word.Document
Dim strActiveDoc As String
Dim lngWordDest As Long




On Error GoTo CreateWordApp
Set wordApp = GetObject(, "Word.Application")
On Error Resume Next



Set WordDoc = wordApp.Documents.Open(strDocName)



strActiveDoc = wordApp.ActiveDocument.Name

WordDoc.MailMerge.OpenDataSource _
Name:=strDataDir & TextMerge, _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False,
_
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=0, _
Connection:="", SQLStatement:="", SQLStatement1:=""




With WordDoc.MailMerge
.Destination = 0
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .datasource
.FirstRecord = 1
'
End With
.Execute Pause:=True
End With
'MyPbar.IncOne ' step 4, doc is merged
WordDoc.Close (False)

wordApp.Windows(wordApp.Windows.count).Activate

Set WordDoc = wordApp.ActiveWindow.Document

Call WordDoc.SaveAs(adrastring, FileFormat:=wdFormatDocument)
Debug.Print "filename: " & WordDoc.Name
''''''''''''''''''''''' Call WordDoc.PrintOut(Background:=False)


Call wordApp.Quit(savechanges:=False)



Set wordApp = Nothing
Set WordDoc = Nothing
' Set MyPbar = Nothing

DoEvents

Exit Function

CreateWordApp:

Set wordApp = CreateObject("Word.Application")
Resume Next

End Function

Function RidesEditTemplate(strWordDoc As String, strSaveDir As String)



Dim wordApp As Object
Dim WordDoc As Object

clsRidesPBar.ShowProgress
clsRidesPBar.TextMsg = "Launching Word...please wait..."

On Error GoTo CreateWordApp
Set wordApp = GetObject(, "Word.Application")
On Error GoTo 0

Set WordDoc = wordApp.Documents.Open(strWordDoc)
wordApp.Visible = True
'*-
WordDoc.MailMerge.MainDocumentType = 0 ' wdFormLetters = 0

WordDoc.MailMerge.OpenDataSource _
Name:=strSaveDir & TextMerge, _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False,
_
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=0, _
Connection:="", SQLStatement:="", SQLStatement1:=""

wordApp.Activate
wordApp.WindowState = 0
clsRidesPBar.HideProgress

Exit Function

CreateWordApp:

Set wordApp = CreateObject("Word.Application")
Resume Next


End Function

Reply With Quote
  #4  
Old   
Bob Barrows
 
Posts: n/a

Default Re: mail merge by Albert D. Kallal new problem - 11-09-2011 , 10:20 AM



You've shown two functions here. Which is failing? Or are both failing?

I suspect the attempt to instantiate Word is raising an error when that is
being hidden by the error handlers. Set a breakpoint, comment out the error
handlers, and step through the code to see what happens.

sparks wrote:
Quote:
Function RidesMergeWord(strDocName As String, strDataDir As String,
adrastring As String)


Debug.Print strDataDir

Dim wordApp As Word.Application
Dim WordDoc As Word.Document
Dim strActiveDoc As String
Dim lngWordDest As Long




On Error GoTo CreateWordApp
Set wordApp = GetObject(, "Word.Application")
On Error Resume Next



Set WordDoc = wordApp.Documents.Open(strDocName)



strActiveDoc = wordApp.ActiveDocument.Name

WordDoc.MailMerge.OpenDataSource _
Name:=strDataDir & TextMerge, _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False,
_
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=0, _
Connection:="", SQLStatement:="", SQLStatement1:=""




With WordDoc.MailMerge
.Destination = 0
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .datasource
.FirstRecord = 1
'
End With
.Execute Pause:=True
End With
'MyPbar.IncOne ' step 4, doc is merged
WordDoc.Close (False)

wordApp.Windows(wordApp.Windows.count).Activate

Set WordDoc = wordApp.ActiveWindow.Document

Call WordDoc.SaveAs(adrastring, FileFormat:=wdFormatDocument)
Debug.Print "filename: " & WordDoc.Name
''''''''''''''''''''''' Call WordDoc.PrintOut(Background:=False)


Call wordApp.Quit(savechanges:=False)



Set wordApp = Nothing
Set WordDoc = Nothing
' Set MyPbar = Nothing

DoEvents

Exit Function

CreateWordApp:

Set wordApp = CreateObject("Word.Application")
Resume Next

End Function

Function RidesEditTemplate(strWordDoc As String, strSaveDir As String)



Dim wordApp As Object
Dim WordDoc As Object

clsRidesPBar.ShowProgress
clsRidesPBar.TextMsg = "Launching Word...please wait..."

On Error GoTo CreateWordApp
Set wordApp = GetObject(, "Word.Application")
On Error GoTo 0

Set WordDoc = wordApp.Documents.Open(strWordDoc)
wordApp.Visible = True
'*-
WordDoc.MailMerge.MainDocumentType = 0 ' wdFormLetters = 0

WordDoc.MailMerge.OpenDataSource _
Name:=strSaveDir & TextMerge, _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False,
_
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=0, _
Connection:="", SQLStatement:="", SQLStatement1:=""

wordApp.Activate
wordApp.WindowState = 0
clsRidesPBar.HideProgress

Exit Function

CreateWordApp:

Set wordApp = CreateObject("Word.Application")
Resume Next


End Function

Reply With Quote
  #5  
Old   
sparks
 
Posts: n/a

Default Re: mail merge by Albert D. Kallal new problem - 11-09-2011 , 10:29 AM



I tried this.

wordApp.Visible = True

the word program opens but there is no document.
I clicked on new document and it opened, ran the code but the saved
document is empty.

for some reason the workd app is open but I do not have anything to
merge the 888 data with.





On Wed, 9 Nov 2011 09:38:58 -0500, "Bob Barrows"
<reb01501 (AT) NOyahooSPAM (DOT) com> wrote:

Quote:
sparks wrote:
I have had this set up and working for a long time.
perfect until now.
I am assuming a microsoft update of some kind.

Set WordDoc = wordApp.Documents.Open(strDocName)

this now says there is no object

Where is wordApp defined and opened? That's the part that must be broken.

Reply With Quote
  #6  
Old   
sparks
 
Posts: n/a

Default Re: mail merge by Albert D. Kallal new problem - 11-09-2011 , 10:33 AM



strActiveDoc = wordApp.ActiveDocument.Name
not an error but when I highlight wordApp.ActiveDocument.Name
I get
this command is not available because no document is open

Reply With Quote
  #7  
Old   
Bob Barrows
 
Posts: n/a

Default Re: mail merge by Albert D. Kallal new problem - 11-09-2011 , 12:12 PM



sparks wrote:
Quote:
I have had this set up and working for a long time.
perfect until now.
I am assuming a microsoft update of some kind.

Set WordDoc = wordApp.Documents.Open(strDocName)

this now says there is no object
Perhaps you misquoted the error, leading me down the wrong path. When you
say "object", I think "object variable" and the only object variable in that
statement is wordApp. After reading your later replies, I now suspect that
strDocName does not contain anything. Add

debug.print strDocName

to find out. If the variable is empty, then Word will not be able to open a
document, now, will it?

Reply With Quote
  #8  
Old   
sparks
 
Posts: n/a

Default Re: mail merge by Albert D. Kallal new problem - 11-09-2011 , 01:23 PM



yep I have the strDocName

On Error GoTo CreateWordApp
Set wordApp = GetObject(, "Word.Application")
On Error Resume Next
wordApp.Visible = True

Debug.Print strDocName
Set WordDoc = wordApp.Documents.Open(strDocName)


this line does nothing

Set WordDoc = wordApp.Documents.Open(strDocName)

I never have a document in word...just the word app is opening but I
no longer have a document

strActiveDoc = wordApp.ActiveDocument.Name

shows <The remote server machine does not exist or is unavailable>

Never saw that before.

Reply With Quote
  #9  
Old   
sparks
 
Posts: n/a

Default Re: mail merge by Albert D. Kallal new problem - 11-09-2011 , 01:25 PM



sorry the machine not available is because I closed the word program.
this is what I get with the app open and no document is created.

strActiveDoc = wordApp.ActiveDocument.Name
not an error but when I highlight wordApp.ActiveDocument.Name

<this command is not available because no document is open>

Reply With Quote
  #10  
Old   
sparks
 
Posts: n/a

Default Re: mail merge by Albert D. Kallal new problem - 11-09-2011 , 01:49 PM



MY GOD

is it against the law to shoot a big shot Fing boss that thinks he
knows everything!!!!!!!!!!!!!!!!!!!!


the moron went in and deleted all the template files because he
thought they just cluttered up the directory.


I AM SORRY for posting all this about it no longer works. the program
knew the name and the location but gave no error when it could not
open the document so I assumed it knew the name and something was
snafu.

AGAIN I AM SORRY for posting and going to all this trouble.

ps can anyone post bail?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.