Open Excel file after creation with transferspreadsheet

  • Thread starter Thread starter Jose Nuñez
  • Start date Start date
J

Jose Nuñez

After creation of an Excel file with transferspreadsheet I would to open
automatically this new file.

I've test using Shell("c:\folder\newfile.xls") but it doesn't work.

How can I do that?

Thanks in advance.
Jose Nuñez
Montevideo
 
From an old post...
To open a specific excel file you can try using FollowHyperlink

Dim strFolderAndFile As String
strFolderAndFile = "C:\folder\newfile.xls"
Application.FollowHyperlink strFolderAndFile


In addition, if you want to invoke Automation Processes, and thereby perform
operations on an excel file, from Access, use this code:

Option Compare Database
Option Explicit ' Use this to make sure your variables are defined

' One way to be able to use these objects throghout the Module is to Declare
them
' Here and not in a Sub

Private objExcel As Excel.Application
Private xlWB As Excel.Workbook
Private xlWS As Excel.Worksheet

Sub Rep()

Dim strFile As String

strFile = "C:\Documents and Settings\ryan\Desktop\YourExcelFile.xls"

' Opens Excel and makes it Visible
Set objExcel = New Excel.Application
objExcel.Visible = True

'Opens up the Workbook
Set xlWB = objExcel.Workbooks.Open(strFile)

'Sets the Workseet to the last active sheet - Better to use the commented
version and use the name of the sheet.
Set xlWS = xlWB.ActiveSheet
'Set xlWS = xlWB("Sheet2")

With xlWS ' You are now working with the Named file and the named worksheet
'Begin formatting, or whatever you want to do…your Excel code goes
here…VEEEEERYYY COOOOLLLL STUFFFF…
End With

'Do Close and Cleanup
End Sub

HTH,
Ryan---
 
Many thanks.

Jose Nuñez


ryguy7272 said:
From an old post...
To open a specific excel file you can try using FollowHyperlink

Dim strFolderAndFile As String
strFolderAndFile = "C:\folder\newfile.xls"
Application.FollowHyperlink strFolderAndFile


In addition, if you want to invoke Automation Processes, and thereby
perform
operations on an excel file, from Access, use this code:

Option Compare Database
Option Explicit ' Use this to make sure your variables are defined

' One way to be able to use these objects throghout the Module is to
Declare
them
' Here and not in a Sub

Private objExcel As Excel.Application
Private xlWB As Excel.Workbook
Private xlWS As Excel.Worksheet

Sub Rep()

Dim strFile As String

strFile = "C:\Documents and Settings\ryan\Desktop\YourExcelFile.xls"

' Opens Excel and makes it Visible
Set objExcel = New Excel.Application
objExcel.Visible = True

'Opens up the Workbook
Set xlWB = objExcel.Workbooks.Open(strFile)

'Sets the Workseet to the last active sheet - Better to use the commented
version and use the name of the sheet.
Set xlWS = xlWB.ActiveSheet
'Set xlWS = xlWB("Sheet2")

With xlWS ' You are now working with the Named file and the named
worksheet
'Begin formatting, or whatever you want to do…your Excel code goes
here…VEEEEERYYY COOOOLLLL STUFFFF…
End With

'Do Close and Cleanup
End Sub

HTH,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top