I have a word document that I created that will be used as a template in one of the apps I'm working one. The user fills out stuff on a VB screen, and the, in turn, get dumped to Bookmarked locations on my template. All of the works. What I can't seem to get working is the SaveAs and having it display on screen prior to being printed. Here is what I have:
VB Code:
  1. Private Sub cmdPrint_Click()
  2. Dim ObjWord As Word.Application
  3. Dim strFileName As String
  4. Set ObjWord = CreateObject("Word.Application")
  5. strFileName = Format(Now, "mmddyyyy HHMMSS")
  6.  
  7.      With ObjWord
  8.          .Documents.Open (App.Path & "\TelephoneLog.doc")
  9.          .ActiveDocument.Bookmarks("prov_info").Select
  10.          .Selection.Text = (cboProvider.List(cboProvider.ListIndex))        
  11.          .ActiveDocument.Bookmarks("fye").Select
  12.          .Selection.Text = (cboFYE.List(cboFYE.ListIndex))
  13.          .ActiveDocument.Bookmarks("type").Select
  14.             If optMeeting.Value = True Then
  15.                .Selection.Text = ("Meeting")
  16.             Else
  17.                .Selection.Text = ("Telephone Conversation")
  18.             End If
  19.          .ActiveDocument.Bookmarks("type").Select
  20.          .Selection.Text = (txtSubject.Text)
  21.          .ActiveDocument.Bookmarks("people").Select
  22.          .Selection.Text = (txtPersons.Text)
  23.          .ActiveDocument.Bookmarks("action").Select
  24.          .Selection.Text = (rtbAction.Text)
  25.          .ActiveDocument.Bookmarks("From").Select
  26.          .Selection.Text = (gstrUserRealName)
  27.           If chkShowDoc.Value = vbChecked Then
  28.                 .Visible = True
  29.           Else
  30.                 .Visible = False
  31.           End If
  32.          .ActiveDocument.PrintOut Background:=True
  33.          .ActiveDocument.SaveAs FileName:=strFileName & ".doc"      
  34.          .Application.Documents.Close
  35.      End With
  36.  
  37.     Set ObjWord = Nothing
  38.  
  39. End Sub
I need to have the document saved as DateTime.doc (i.e., 08052005 092820.doc), and I need to set it up so that user can either display it on the screen prior to printing, or never see it and send it directly to the printer.