?
Solved

Exporting Access Memo fields to Excel

Posted on 2011-02-22
3
Medium Priority
?
565 Views
Last Modified: 2012-05-11
I'm trying to export an Access query to Excel, but the memo fields get truncated.

My initial thought here is to programatically divide up this Memo data (up to 2000 characters) into smaller chunks and export it to seperate rows.

Before I do that, are there any Excel tricks I am overlooking to avoid this?
0
Comment
Question by:mbizup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Helen Feddema earned 2000 total points
ID: 34953322
Set a variable of Variant type to the Memo field, then write it to a cell using Range.Value:
Public Sub ExportMemoField()

   Dim strCurrentPath As String
   Dim wkb As Excel.Workbook
   Dim appExcel As New Excel.Application
   Dim rst As DAO.Recordset
   Dim varMemo As Variant
   Dim strWorkbook As String
   Dim sht As Excel.Worksheet
   Dim strRange As String
   Dim rng As Excel.Range
   
   strCurrentPath = Application.CurrentProject.Path & "\"
   Set wkb = appExcel.Workbooks.Add
   appExcel.Visible = True
   'strWorkbook = strCurrentPath & "Memo Field.xls"
   'wkb.SaveAs FileName:=strWorkbook
   Set sht = wkb.Sheets(1)
   strRange = "A1"
   Set rng = sht.Range(strRange)
   Set rst = CurrentDb.OpenRecordset("tblContacts")
   
   Do While Not rst.EOF
      varMemo = rst![Notes]
      If IsNull(varMemo) = False Then
         rng.Value = CStr(varMemo)
         Set rng = appExcel.ActiveCell.Offset(rowoffset:=1)
      End If
      rst.MoveNext
   Loop
      
   Set appExcel = Nothing
   
End Sub

Open in new window

0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 34953338
You may need to redo your code to do the entire export in code, rather than exporting the whole query.
0
 
LVL 61

Author Comment

by:mbizup
ID: 34953469
Helen,

Thanks - that works.

Not as elegant, but I also found that if I change my query to a make-table query and export the table instead of the query, the truncation does not occur.

no idea why...

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question