473,378 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Open Excel spreadsheet with Access

3
I am trying to open a spreadsheet from Acess based on a value in a textbox. I don't how to create the reference to the path and file name and was wondering if someone could help. I am new to VBA and think I am close but need a bit of assitance. Below is the code I created:

Dim oApp As Object
Dim Path1 As String
Dim Path2 As String
Dim Full_Path As String

Path1 = "\\Budget_Tracking\"
Path2 = Text1.Value
Full_Path = Path1 & Path2


Set oApp = CreateObject("Excel.Application")
oApp.Workbooks.Open Filename:=Full_Path
oApp.Visible = True
oApp.UserControl = True
Apr 17 '07 #1
5 44252
maxamis4
295 Expert 100+
Here is an example of one of my codes"

Remember to include the excel reference library.

hope this helps, this is per your request open an excel file from access
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnExport_Click()
  2. ' Exports data from port order to excel spread sheet.
  3. On Error Resume Next
  4.  
  5.     Dim objApp As Excel.Application
  6.     Dim objBook As Excel.Workbook
  7.     Dim objSheet As Excel.Worksheet
  8.     Dim sSQL As String
  9.     Dim Path As String
  10.  
  11.     Set db = CurrentDb()
  12.  
  13.      Set objBook = Workbooks.Add(Template:=CurrentProject.Path & Path1 & Path2)  'Your excel spreadsheet file goes here
  14.                 Set objApp = objBook.Parent
  15.                     Set objSheet = objBook.Worksheets("YOUR SHEETNAME") 'Name of sheet you want to View
  16.                        objBook.Windows(1).Visible = True
  17.                        objApp.Visible = True
  18.  
  19.  
  20.  
  21. End Sub
  22.  

I am trying to open a spreadsheet from Acess based on a value in a textbox. I don't how to create the reference to the path and file name and was wondering if someone could help. I am new to VBA and think I am close but need a bit of assitance. Below is the code I created:

Dim oApp As Object
Dim Path1 As String
Dim Path2 As String
Dim Full_Path As String

Path1 = "\\Budget_Tracking\"
Path2 = Text1.Value
Full_Path = Path1 & Path2


Set oApp = CreateObject("Excel.Application")
oApp.Workbooks.Open Filename:=Full_Path
oApp.Visible = True
oApp.UserControl = True
Apr 17 '07 #2
Roo06
3
Thanks for the reply. I am not sure that address my need to have the name of the workbook be dynamic.

My problem is I need to open a certain workbook based on the value of a textbox.

Ex: texbox1 = 54362

I would want to open a workbook name 54362.xls.

The path would always be the same but the workbook name would change depending on what record is being viewed.
Apr 17 '07 #3
maxamis4
295 Expert 100+
I did post that for you. If you notice the path where the work book is being called, I used your variables path1 & Path2, where you set path2 = textbox1

Let me know if you need more assistance.

Thanks for the reply. I am not sure that address my need to have the name of the workbook be dynamic.

My problem is I need to open a certain workbook based on the value of a textbox.

Ex: texbox1 = 54362

I would want to open a workbook name 54362.xls.

The path would always be the same but the workbook name would change depending on what record is being viewed.
Apr 18 '07 #4
Roo06
3
Now I got it. I totally missed it until you pointed it out. Your solution worked like a charm. Thanks again for your help.


I did post that for you. If you notice the path where the work book is being called, I used your variables path1 & Path2, where you set path2 = textbox1

Let me know if you need more assistance.
Apr 18 '07 #5
pks00
280 Expert 100+
If all u want to do is open a excel file, why not try this

application.followhyperlink Full_Path


Is there any reason why u are using excel automation. I understand you are new to this, Im just wondering whether u are going to do any edits to this excel file
Apr 18 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
1
by: Johnny Meredith | last post by:
Dear All, I have an Access database that tracks the progress of income tax audits. When the taxing authorities make a change (an "Adjustment"), I record the pertinent information in the...
6
by: Daniel | last post by:
Hi all, Can i open and edit the excel sheet on web page after downloading? After editing, i close the web page and the excel file auto upload to the server. Is it possible? I really struggling...
6
by: Syvman | last post by:
Here's what I've got: I'm trying to grab some data out of an Excel spreadsheet and bring it into Access. I'm able to do it, but only if the Excel spreadsheet is not opened by any other users. I...
2
by: Peter S. | last post by:
I have an ASP.NET page that invokes a web control written in C#. What I want to do is (based on the session ID) display a certain spreadsheet that exists on a network drive. I want the webcontrol...
3
by: toffee | last post by:
Hi all, I got a pre-formatted spreadsheet. would it be possible using js to copy the data from a table on the current webpage, open the spreadsheet and paste the content ? if so, anyone got any...
12
by: slinky | last post by:
Can an Excel spreadsheet or a section of one be embedded into an Access form and serve as a subform from which other parts of the Access form can get data? Thanks!
0
by: Tony Hine | last post by:
Problem for Excel Developers One of the problems facing Excel developers moving into MS Access is actually the apparent similarity between MS Access tables and Excel spreadsheets. MS Access is...
1
by: evenlater | last post by:
I have an Access 2007 application running on a terminal server. One of the features of the app is a wizard that allows them to create an Excel spreadsheet by querying the Access data. When they...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.