[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Exporting Access Memo fields to Excel

Posted on 2011-02-22
3
Medium Priority
?
571 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

650 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