ok let me try to explain what I've got. I am trying to save to a word document through vba. I have 2 text boxes on my form and I would like to save the 2 text boxes in the word doc. just like there are on the form, right next to each other. I am using this code to save.
the lab and recname are fine. the ingredients and proc are the ones I need to align. right now it saves the ingredients fine but it saves proc right underneath the ingredients. is it possible to keep the text box size, the proc is in, the same in the .doc file. right now it is saving it as one long line. like thisCode:Private Sub mnuSaveAs_Click() Dim filenum As Integer Dim Ingredients As String Dim lab As String Dim recname As String Dim proc As String Dim strMsg As String Dim W As New _ Word.Application Ingredients = TxtIngredients.Text lab = Label1.Caption recname = LblName.Caption proc = TxtProcessTest mnuSaveAs.Enabled = False If TxtProcessTest.Text = "" _ Then MsgBox "You cannot use a blank TextBox", vbCritical, _ "Entry Error" mnuSaveAs.Enabled = True Exit Sub Else strMsg = lab & vbTab & recname & vbCrLf & vbNewLine & Ingredients & vbTab & _ vbTab & proc End If W.Documents.Add W.Selection.TypeText (strMsg) W.ChangeFileOpenDirectory (App.Path) W.ActiveDocument.SaveAs Filename:=recname & ".doc", _ FileFormat:=wdFormatDocument, _ LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", _ ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _ _ SaveNativePictureFormat:=False, SaveFormsData:=False, _ _ SaveAsAOCELetter:=False W.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges W.Application.Quit Set W = Nothing strMsg = "The document, " & recname & _ ".doc" & vbCrLf strMsg = strMsg & "has be saved in the directory, " & _ App.Path & "." MsgBox strMsg mnuSaveAs.Enabled = True End Sub 'Code improved by vBulletin Tool (Save as...)
ingredient 1
ingredient 2
ingredient 3
proc ----------------------------------
----------------------------------------------------
---------------------------
something like that. I want it to save it like this
ingredient 1 proc--------------------------
ingredient 2 --------------------------------
ingredient 3 ------------------------------
does that make since? also what about keeping the same font size when saving as it is on the form?
Scoutt




Reply With Quote