Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSV Text File export Problems

    I am currently having problems with our access database when it exports information to a csv text file.

    We export to a csv text file to then do a mailmerge via vba code for a particular record.

    However I have noticed that in the text file when there are numbers they are not enclosed in speech marks. All the other text fields are.

    When I am trying to execute this via command button it does not run, which I presume is because of the fact that the numbers need speech marks round them.

    Any ideas?
    Best Regards,

    Luke

  2. #2
    Administrator
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    12,519
    Thanks
    152
    Thanked 1,398 Times in 1,221 Posts
    Those numbers, when they appear, are they data for Access number fields? If they are, that's just how export works, only Access text fields are enclosed in double quotes.

  3. #3
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, thanks. Still not getting anywehre with it.

    Thinking of changing my merges to be based upon bookmarks rather than text file imports.

    However I have some code that I am looking at from the MS website sample and cannot see a way to be able to select the printer from the normal print dialogue box.

    Dim objWord As Word.Application

    'Copy the Photo control on the Employees form.
    DoCmd.GoToControl "Photo"
    DoCmd.RunCommand acCmdCopy

    'Start Microsoft Word 97.
    Set objWord = CreateObject("Word.Application")

    With objWord
    'Make the application visible.
    .Visible = True

    'Open the document.
    .Documents.Open ("C:\MyMerge.doc")

    'Move to each bookmark and insert text from the form.
    .ActiveDocument.Bookmarks("First").Select
    .Selection.Text = (CStr(Forms!Employees!FirstName))
    .ActiveDocument.Bookmarks("Last").Select
    .Selection.Text = (CStr(Forms!Employees!LastName))
    .ActiveDocument.Bookmarks("Address").Select
    .Selection.Text = (CStr(Forms!Employees!Address))
    .ActiveDocument.Bookmarks("City").Select
    .Selection.Text = (CStr(Forms!Employees!City))
    .ActiveDocument.Bookmarks("Region").Select
    .Selection.Text = (CStr(Forms!Employees!Region))
    .ActiveDocument.Bookmarks("PostalCode").Select
    .Selection.Text = (CStr(Forms!Employees!PostalCode))
    .ActiveDocument.Bookmarks("Greeting").Select
    .Selection.Text = (CStr(Forms!Employees!FirstName))

    'Paste the photo.
    .ActiveDocument.Bookmarks("Photo").Select
    .Selection.Paste
    End With

    'Print the document in the foreground so Microsoft Word will not close
    'until the document finishes printing.
    objWord.ActiveDocument.PrintOut Background:=False

    'Close the document without saving changes.
    objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

    'Quit Microsoft Word and release the object variable.
    objWord.Quit
    Set objWord = Nothing
    Exit Sub

    MergeButton_Err:
    'If a field on the form is empty, remove the bookmark text, and
    'continue.
    If Err.Number = 94 Then
    objWord.Selection.Text = ""
    Resume Next

    'If the Photo field is empty.
    ElseIf Err.Number = 2046 Then
    MsgBox "Please add a photo to this record and try again."
    Else
    MsgBox Err.Number & vbCr & Err.Description
    End If

    Exit Sub
    End Sub
    Best Regards,

    Luke

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Are you really running this on Word 97 (and presumably Access 97) or are those just comments in the code? Also, are you wanting to give the user the choice of printer to use, or are you always trying to print to a certain printer? The PrintOut option sends it to the default printer for that workstation. If you want to select a specific printer, you will also need to deal with issues where that printer isn't defined for a specific workstation.
    Wendell

  5. #5
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not sure what I have done, but it all seems to be working!

    Very strange......
    Best Regards,

    Luke

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •