Linking to File from VB

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows
There are many ways, depending on what you actually want to do and the type of file.

You could use a hyperlink.

You coud use Shell.

You could automate the application the file is associated with.
 

shajueasow

Well-known Member
Joined
Oct 7, 2004
Messages
1,926
Try using
Workbooks.Open Filename:= "Your Path and File name"

Assumed that you are trying to open an excel file.
 

stevenwhickey

New Member
Joined
Apr 4, 2006
Messages
42
I want to open an excel file from another application. When I used

Workbooks.Open Filename:="H:\Desktop\Spreadsheets & Databases\Alaska.xls" it told me that it wasn't defined.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

What's the other application?
 

stevenwhickey

New Member
Joined
Apr 4, 2006
Messages
42
It is a custom made application that allows the ability to create macros using VB. It isn't anything well known.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Steven

It might help us to help you if we knew what the application is.:)

Does it support VBA?
 
L

Legacy 98055

Guest
Reflections for Regis Graphics? IBM? Terminal Emulator? More details please.

Please invest some time into your post so we don't have to spend so much time asking you questions to try and figure out how to help you. If you simply want to open up a workbook and have no intention on further interaction with this workbook, use the Shell API function. I would not use this code from within Excel hosted VBA to open a workbook.

<table width="100%" border="1" bgcolor="White" style="filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');"><tr><TD><font size="2" face=Courier New>  <font color="#0000A0">Private</font> <font color="#0000A0">Declare</font> <font color="#0000A0">Function</font> ShellExecute <font color="#0000A0">Lib</font> "shell32.dll" <font color="#0000A0">Alias</font> "ShellExecuteA" _
       (ByVal hwnd <font color="#0000A0">As</font> Long, <font color="#0000A0">ByVal</font> lpOperation <font color="#0000A0">As</font> String, <font color="#0000A0">ByVal</font> lpFile <font color="#0000A0">As</font> String, _
       <font color="#0000A0">ByVal</font> lpParameters <font color="#0000A0">As</font> String, <font color="#0000A0">ByVal</font> lpDirectory <font color="#0000A0">As</font> String, <font color="#0000A0">ByVal</font> nShowCmd <font color="#0000A0">As</font> Long) <font color="#0000A0">As</font> <font color="#0000A0">Long</font>

  <font color="#0000A0">Sub</font> Example()
       <font color="#0000A0">Dim</font> WbPath <font color="#0000A0">As</font> <font color="#0000A0">String</font>
       WbPath = "C:\Documents and Settings\Somebody\YouWorkbook.xls"
       <font color="#0000A0">Call</font> ShellExecute(0, "Open", WbPath, "", "", 1)
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>
</FONT></td></tr></table><button onclick='document.all("927200623332781").value=document.all("927200623332781").value.replace(/<br \/>\s\s/g,"");document.all("927200623332781").value=document.all("927200623332781").value.replace(/<br \/>/g,"");window.clipboardData.setData("Text",document.all("927200623332781").value);'>Copy to Clipboard</BUTTON><textarea style="position:absolute;visibility:hidden" name="927200623332781" wrap="virtual">
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

Sub Example()
Dim WbPath As String
WbPath = "C:\Documents and Settings\Somebody\YouWorkbook.xls"
Call ShellExecute(0, "Open", WbPath, "", "", 1)
End Sub</textarea>

If your overall purpose is to share data between your Reflection session and the workbook, you need to specify this.
 

Forum statistics

Threads
1,136,260
Messages
5,674,697
Members
419,520
Latest member
Jennifer4Dillon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top