Solved

Exporting Access Memo fields to Excel

Posted on 2011-02-22
3
551 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
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Remove row and column 3 45
Adding Text that self adjusts in a Cell 8 31
Excel for Mac - How make those Tabs larger? 2 31
ADD New Entries 7 15
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

929 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now