• word from Access (access2000)

    Author
    Topic
    #364428

    Hi guys!
    When I open word form access it only opens as a very small square on the top left hand corner. I cannot see anything nor can I maximise it.
    If you have a look at the screen shot I’ve attached you’d know what I mean.
    Please help to overcome this problem??

    SORRY couldn’t attach it. anyways its very small & when I maximise it it only shows the scrolling bar. To open the document, I have to close and open it .

    Viewing 1 reply thread
    Author
    Replies
    • #559420

      How exactly are you opening it from Access? You can’t assume everyone has read all your other posts.

      • #559994

        Im using a module to open word.

        • #560036

          That isn’t specific enough. Post the code.

          • #560045
            Option Compare Database
            Const CSTR_SAVEPATH As String = "S:SRI_WORK_AREADOCUME~1"
            Const CSTR_DOCSPATH As String = "T:TradeAdminSysDevelopment"
            Sub CitcoFax()
            Dim strFileName As String, strMsg As String, vResult As Variant
            Dim strFilenamePart As String, appWord As Object
            Dim db As DAO.Database
            Dim rst As DAO.Recordset
            Dim rstRecipients As DAO.Recordset
            Dim strFund As String
            Dim rstCitco As DAO.Recordset
            Dim strTDate As Date
            Dim objWord As Object, strMessage As String, strMsgTitle As String
            strFund = "Soros"
            'Turn System warnings off
            DoCmd.SetWarnings False
            'Delete contents of the table
            DoCmd.RunSQL "DELETE [tblCitco].* FROM [tblCitco] WITH OWNERACCESS OPTION;", 0
            'Run Append query to add SFM records to the table
            DoCmd.OpenQuery "AppToCitco", acNormal, acEdit
            'Turn System warnings on.
            DoCmd.SetWarnings True
            'message to remind user to close any active word documents.
            MsgBox "Close any active word documents, click on OK to continue.",  _
                  vbInformation + vbMsgBoxSetForeground, strMsgTitle
            Set db = CurrentDb
            Set rst = db.OpenRecordset("tblCitco")
            If rst.BOF And rst.EOF Then
               vResult = MsgBox("There are no records. Would you like to send a fax?", _
               vbQuestion + vbYesNo + vbMsgBoxSetForeground)
               If vResult = vbYes Then
                  'set value to merge
                  Set rstRecipients = db.OpenRecordset("tblRecipient", dbOpenDynaset)
                  With rstRecipients
                    .MoveFirst
                    .FindFirst "[Fund] = '" & strFund & "'"
                    .Edit
                    !Merge = True
                    .Update
                  End With
                  Set rstRecipients = Nothing
                  'Output data to spreadsheet
                  strFileName = CSTR_DOCSPATH & "FAXSOURCE.xls"
                  DoCmd.OutputTo acOutputQuery, "qryRecipient", acFormatXLS, strFileName, False
                  'Open fax cover
                  Set objWord = GetObject(CSTR_DOCSPATH & "Fax.doc", "Word.Document")
                  'Make word visible
                  With objWord
                    .Application.Visible = True
                    'Execute the mail merge
                      With .MailMerge
                        .destination = wdSendToNewDocument
                        .Execute
                      End With
                      Set appWord = .Application
                  End With
                  appWord.DisplayAlerts = wdAlertsNone
                  objWord.Close
                  appWord.DisplayAlerts = wdAlertsAll
                  'Update tblRecipient
                  DoCmd.OpenQuery "UpdRecipients(Merge)", acNormal, acEdit
               Else
               End If
            Else
               strFileName = CSTR_DOCSPATH & "BCPSOURCE.xls"
               DoCmd.OutputTo acOutputQuery, "Citco", acFormatXLS, strFileName, False
               Set objWord = GetObject(CSTR_DOCSPATH & "Citco.doc", "Word.Document")
               'set value to Date
                  Set rstCitco = db.OpenRecordset("tblCitco", dbOpenDynaset)
                  With rstCitco
                  TDate = rst![tradedate]
                  End With
               'Make word visible.
               With objWord
                  .Application.Visible = True
                  'Execute the mail merge.
                  With .MailMerge
                     .destination = wdSendToNewDocument
                     .Execute
                  End With
                  Set appWord = .Application
               End With
               appWord.DisplayAlerts = wdAlertsNone
               objWord.Close
               appWord.DisplayAlerts = wdAlertsAll
               strFileName = CSTR_SAVEPATH & "CitcoFax" & Format(TDate, "DDMMYY") & ".doc"
               strMsgTitle = "Buttonwood Trade Administration System"
               vResult = Dir(strFileName)
               If vResult  "" Then
                  strMessage = "File " & strFileName & " already exists," & _
                  vbCrLf & vbCrLf & "Would you like to overwrite that file?" & _
                  vbCrLf & vbCrLf & "Click Yes to overwrite the file" & _
                  vbCrLf & vbCrLf & "Click No to save the file with another name" & _
                  vbCrLf & vbCrLf & "Click Cancel to return to the document without saving."
                  vResult = MsgBox(strMessage, vbQuestion + vbYesNoCancel + vbMsgBoxSetForeground, strMsgTitle)
                  Select Case vResult
                     Case Is = vbYes
                        With appWord
                           .DisplayAlerts = False
                           .activedocument.SaveAs filename:=strFileName, FileFormat:=wdFormatDocument
                           MsgBox "Document has been saved.", vbInformation + vbMsgBoxSetForeground, _
                                     strMsgTitle
                           .DisplayAlerts = True
                        End With
                     Case Is = vbNo
                        strFileName = InputBox("File " & strFileName & " already exists," _
                        & Chr(10) & "Please enter another filename not including " _
                        & Chr(34) & ".doc" & Chr(34) & ": ") & ".doc"
                        If strFileName = ".doc" Then
                           MsgBox "You've clicked on cancel," _
                           & " the document has not been saved.", vbInformation + vbMsgBoxSetForeground, strMsgTitle
                        Else
                           appWord.activedocument.SaveAs _
                           filename:=CSTR_SAVEPATH & strFileName, FileFormat:=wdFormatDocument
                           MsgBox "Document has been saved.", vbInformation + vbMsgBoxSetForeground, _
                                    strMsgTitle
                        End If
                     Case Else
                     MsgBox "You've chosen not to save the document.", vbInformation + vbMsgBoxSetForeground,  _
                              strMsgTitle
                  End Select
               Else
                  With appWord
                     .DisplayAlerts = False
                     .activedocument.SaveAs filename:=strFileName, _
                     FileFormat:=wdFormatDocument
                     .DisplayAlerts = True
                     MsgBox "Document has been saved.", vbInformation + vbMsgBoxSetForeground, _
                                     strMsgTitle
                  End With
               End If
               AppActivate "Microsoft Word"    ' Activate Microsoft Word.
               End If
            cleanup:
               On Error Resume Next
               Set objWord = Nothing
               Set appWord = Nothing
               Set rst = Nothing
               Set db = Nothing
            End Sub
            

            Edited by Charlotte to reduce horizontal scrolling

            • #560054

              OK, we can see what you’re doing. One problem with this is that you aren’t closing Word from it before you destroy the object variables. That means Word is going to be left open, whether that’s what you intended or not, which is untidy and likely to cause you problems.

              Now, what exactly is it you’re trying to do? You’ve already sent you fax or done the mail merge, so what is the purpose of activating Word?

            • #560055

              Ok, What Im doing here are as follows:
              Run the queries
              Merge document
              Output to new document
              Save document
              Allow user to view document (this is why word is activated so that user could edit or print report and do whatever with it.)
              smile

            • #560128

              But the user has *already* created the fax or mal merge. What are they going to do with it after that? It’s already a done deal. shrug

            • #560243

              Yes charlotte, you’re right but I don’t want to save the document as a merged document coz the data on these documents will change everyday that is why I sending all the data on the merged document to a new document and save it and then allow the user to open it. As you can see in the code the merged document is called Citco.doc and the new document created everytime I run the code is saved as citco followed by todays date.

            • #560244

              No worries guys! I am sure the users will be able to close word and re open it.
              Thanx for trying.
              bow

            • #560281

              You lost me. Didn’t you already save the created document , which *is* a merged document? You’re creating a new file name and saving each one in the code.

              If you want to maximize Word, you should be able to do it like this when you first get started:

              ‘ Make Word visible and maximize
              objWord.Application.WindowState = wdWindowStateMaximize
              objWord.Application.Visible = True

              You might try appWord.Activate instead of AppActivate “Microsoft Word” at the end and see if that’s any improvement.

            • #560294

              Thanx Charlotte bow
              Thats all I want to know.
              Have a HAPPY new year!
              smile

    • #560224

      Why don’t you force the Word to maximize and use Message Box to block the process and keep the Word visible. Check it out at http://www.helptalk.net/forums/access/messages/156344.html


      obj.WindowState = 1

      HTH.
      Tim K.

    Viewing 1 reply thread
    Reply To: word from Access (access2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: