VB for excel; open file.....
#1
Scooby Regular
Thread Starter
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like
on
1 Post
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]
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]
#2
Scooby Regular
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes
on
0 Posts
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
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
#3
Scooby Regular
Thread Starter
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like
on
1 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 ??
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 ??
#5
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
Workbooks.Open Filename:= "FileNameHere"
So stick the filename in "A1" and use
Workbooks.Open Filename:=Range("A1").Value
Deano
#6
Scooby Regular
Join Date: Sep 2002
Location: Essexville
Posts: 4,391
Likes: 0
Received 0 Likes
on
0 Posts
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
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
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
alcazar
Computer & Technology Related
2
29 September 2015 07:18 PM