A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

writing to excel from outlook



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old January 3rd 10, 04:03 PM posted to microsoft.public.outlook.program_vba
pete the greek
external usenet poster
 
Posts: 6
Default writing to excel from outlook

hi im trying to us excel to log whick folders i access within my email and
am
struggling with the automation between outloook and excel

i appear to be able to do this by creating a new excel object and then
opening the excel file writing the info and then closing it again see code
below.

what i would like to do is leave the escel file open as i assume this
would
be quicker but if i do this creatobject opens the file as read only in the
background

i think i need to use getobject to pick up the open file but cant get it
to
work any pointers

code:

Sub log()

Set MyApp = CreateObject("excel.application")



Set objNS = Application.GetNamespace("MAPI")
Set thisfolder = Application.ActiveExplorer.CurrentFolder

MyApp.workbooks.Open "C:\Documents and Settings\Peter\My
Documents\test.xls", ReadOnly:="false"
MyApp.workbooks("test.xls").worksheets(1).Range("A 1").Select
MyApp.Selection.entirerow.Insert
MyApp.workbooks("test.xls").worksheets(1).Range("A 1").Value =
thisfolder.Name



MyApp.workbooks("test.xls").Close (True)



End Sub


 




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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help for writing an Outlook 2007 macro LGM Outlook and VBA 7 December 23rd 09 03:28 PM
Replacing or Over writing Outlook PST Files Paul Brown Outlook - Calandaring 2 September 26th 09 10:47 PM
Outlook 2003 stops writing gunsan Outlook - General Queries 1 July 13th 09 07:45 AM
Can't see outlook contacts when writing an email J Goldsmith Outlook - Using Contacts 6 November 20th 07 01:24 PM
Writing a macro in Outlook 2007 Tammy Outlook - General Queries 2 May 8th 07 03:47 PM


All times are GMT +1. The time now is 12:59 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.