PC Review


Reply
Thread Tools Rate Thread

Activate Excel Window Upon Export from Access

 
 
SMT
Guest
Posts: n/a
 
      28th May 2009
I want to make the Excel window the active window upon export from Access.
Wasnt sure what code to use and where to put it (Excel or Access) Below I
have included both the code for the export out of Access and the code that I
have in Excel. Any help would be appreciated. Right now after I hit the
export button the dialog box that allows the user to select a folder appears
in the background behind Access window.

Export button in Access

DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, "qryGraphExportStep4Dept", _
"\\naeanrfkfs27\C163\Navsea_inhd_nswc03\C6\Shared\CompleteAndOnTime\qryGraphExportStep4.xlt", , "qryGraphExportStep4"
Application.FollowHyperlink
"\\naeanrfkfs27\C163\Navsea_inhd_nswc03\C6\Shared\CompleteAndOnTime\qryGraphExportStep4.xlt"

_______
Auto_open macro in excel file

If Application.ActiveWorkbook.Name <> (Range("R1").Value & "_" &
Range("Q1").Value & "_" & Format(Date, "mmdd") & ".xls") Then
MsgBox "Please select the folder in which to save your file. You do not
need to add a file name. A file name will be generate automatically using
Reporting Area, Customer Type, and Todays Date as the file name."
' Open the file dialog
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.InitialFileName = Environ("USERPROFILE") & "\"
.Show
mydir = .SelectedItems(1)
End With

If Len(mydir) = 0 Then mydir = "C:"
If Mid(mydir, Len(mydir), 1) = "\" Then mydir = Left(mydir, Len(mydir) -
1)
ActiveWorkbook.SaveAs Filename:=mydir & "\" & Range("R1").Value & "_" &
Range("Q1").Value & "_" & Format(Date, "mmdd"),
FileFormat:=Excel.XlFileFormat.xlWorkbookNormal
MsgBox "Your file was saved to " & mydir & ". Reporting Area, Customer
Type, and Todays Date were used as the file name."
End If

End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activate Excel Window Upon Export from Access SMT Microsoft Access VBA Modules 0 28th May 2009 02:01 PM
Workbook.Activate / Window.Activate problem Tim Microsoft Excel Programming 3 3rd Feb 2006 11:38 PM
activate a Word Window from Excel VBA =?Utf-8?B?YmVu?= Microsoft Excel Programming 1 17th Feb 2005 06:57 PM
ACTIVATE ACCESS from EXCEL? Joyce Microsoft Excel Misc 1 23rd Sep 2004 02:57 PM
Activate Non-Excel Window Through VBA Mark Bigelow Microsoft Excel Programming 1 3rd Sep 2003 07:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:04 PM.