Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions


Fill in a brief DW Simpson Registration Form
to be contacted when new jobs meet your criteria.


Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old 09-28-2017, 12:05 PM
Freebird's Avatar
Freebird Freebird is offline
Member
SOA AAA
 
Join Date: Dec 2001
Location: Topeka, Kansas
College: Graduated from Ohio State too many years ago to remember
Favorite beer: Newcastle
Posts: 824
Default

Quote:
Originally Posted by dumples View Post
Not trying to be a jerk, but it would take me longer to put it here than it would take for you to google "Excel VBA CopyFromRecordSet example"
No offense taken, dumples. There are probably a million ways to import into Excel from Access, and so I added CopyFromRecordset to my search string. It was a good suggestion, because I got the following official code below from Microsoft.

Thanks to all for your suggestions!

Sub GetQuery()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim i As Long
Dim wsh As Worksheet
Set dbs = DBEngine.OpenDatabase(Put path and filename here)
Set rst = dbs.OpenRecordset(Put query name here)
Set wsh = Worksheets(Put sheet name here)
For i = 0 To rst.Fields.Count - 1
wsh.Cells(1, i + 1).Value = rst.Fields(i).Name
Next
wsh.Range("A1").Resize(ColumnSize:=rst.Fields.Coun t).Font.Bold = True
wsh.Range("A2").CopyFromRecordset rst
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
End Sub
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 12:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.10854 seconds with 9 queries