Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

VB for excel; open file.....

Thread Tools
 
Search this Thread
 
Old 31 October 2002, 06:05 AM
  #1  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Question

Any one know the command to open a specific file in a specific location.

Idealy looking to put the file name in a certain excel cell, and then a macro opens the specified file, then does certain operations.

The crux is getting the macro to open any file !!

Ta.

[edited to make more sense]

[Edited by velohead66 - 11/5/2002 8:16:01 AM]
Old 31 October 2002, 08:55 AM
  #2  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

you mean open the file with the windows associated application?

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

ShellExecute0, vbNullString, "C:\test.doc", vbNullString, vbNullString, vbNormalFocus
or
ShellExecute0, vbNullString, "http://www.website.com", vbNullString, vbNullString, vbNormalFocus
Old 02 November 2002, 07:38 AM
  #3  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Post

em, seems a bit complicated, and it doesnt seem to work.
Error message is "sub or function not defined".
"ShellExecute0" is highlighted in blue.

Presume this is "VB for excel" rather then "VBA" ??

Thought the statement might be more simple,
and of the order of "filename.xls.openfile"
or similiar ??
Old 05 November 2002, 05:45 AM
  #4  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Question

...anyone ??????
Old 05 November 2002, 08:49 AM
  #5  
dsmith
Scooby Regular
 
dsmith's Avatar
 
Join Date: Mar 1999
Posts: 4,518
Likes: 0
Received 0 Likes on 0 Posts
Post

Well from a simple "Macro Record" and look at the code I think you want

Workbooks.Open Filename:= "FileNameHere"

So stick the filename in "A1" and use

Workbooks.Open Filename:=Range("A1").Value

Deano
Old 05 November 2002, 03:48 PM
  #6  
beemerboy
Scooby Regular
 
beemerboy's Avatar
 
Join Date: Sep 2002
Location: Essexville
Posts: 4,391
Likes: 0
Received 0 Likes on 0 Posts
Post

exactimundo deano....

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 05/11/2002 by daren williams
'

'
Workbooks.Open Filename:= _
"C:\Documents and Settings\daren\My Documents\Clients.xls"
End Sub
Old 07 November 2002, 06:22 AM
  #7  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Cool

Ta.

Forgot rule number one, record it if poss.

Good rule to learn I guess.
Effective, and Simple Too.

Thanks Again.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
leg200
Subaru Parts
5
07 October 2015 07:31 AM
alcazar
Computer & Technology Related
2
29 September 2015 07:18 PM



Quick Reply: VB for excel; open file.....



All times are GMT +1. The time now is 01:44 PM.