PDA

View Full Version : Macro Quits Working Properly



timeless
01-26-2012, 07:59 PM
I have an outlook macro that I run from an outlook contact card. the macro opens up an excel workbook and then puts the contact File As name in a cell in the spreadsheet. The maco works fine until I open up my dictating software dragon naturally speaking. Running Outlook & Excel 2010, Windows 7 and Dragon Natuarlly Speaking 11.5
when the macro is working fine it opens the workbook puts the file as name in the right cell and the workbook becomes the active window on my screen
When the dictation software is open it does everything but the contact card remains the active screen and the worksheet is active in the background. I often have different excel workbooks open and the code opens my workbook in a new session of Excel
I am a hack and copied the code modified it but do not really understand it
I have pasted my code below

Sub OpenRTLog()
Dim objContact As Outlook.ContactItem
Set objContact = Application.ActiveInspector.CurrentItem
MyValue = objContact.FileAs
Dim objExcel As Object
Dim objWB As Object
Set objExcel = CreateObject("Excel.Application")
Set objWB = objExcel.Workbooks.Open("C:\00 CapSheet\RTLog.xlsm")
objExcel.Visible = True
objExcel.Cells(1, 2).Value = MyValue
End Sub

Thanks

JP2112
02-02-2012, 08:25 AM
Welcome to the board. Please use tags when posting code.

Your chief complaint seems to be that when you run the code, it activates Excel and makes it the active window. When your dictation software is open, the code leaves the Outlook contact card as the active window.

I'm confused about why this is a problem. Just click on Excel in the taskbar to activate it. Or, don't open the contact card and adjust the code to take the selected item instead. That way, the contact card would never be open and so would never be the active window.

timeless
02-02-2012, 01:26 PM
Reply as to why not just click excel on the taskbar after running macro -
I often have several excel applications open so when I click the button on my quick access toolbar from my outlook contact card and excel does not become the active window I have to mouse down to the task bar, wait for the open workbook list window to pop up then click the workbook, then mouse back up to the top of the sreen to click from a variety of macros I have assigned to other buttons on my excel worksheet. It is a pain versus clicking the button and the excel window immediatedly appearing.

reply as to don't open the contact card - The outlook contact card is always open first because I am contacting people and need their phone number to dial before adding their name to the excel spread sheet.