ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open other applications using code (https://www.excelbanter.com/excel-programming/415224-open-other-applications-using-code.html)

SJW_OST[_2_]

Open other applications using code
 
I want to have Excel open Windows Explorer to a specific drive location, ie
C:\MyFolder.
I also want Excel to open Internet Explorer to a specific intranet site.
Can either of these actions be done thru Excel VB?

Thanks for any help.

ryguy7272

Open other applications using code
 
I am assuming that you want to import and Excel file into an existing
worksheet. Is that right?
Sub Import()
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Dim x As Long
Dim FilesToOpen


FilesToOpen = Application.GetOpenFilename _
(FileFilter:="Text Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Excel Files to Open")

Set Wb1 = ActiveWorkbook
For x = LBound(FilesToOpen) To UBound(FilesToOpen)
Set Wb2 = Workbooks.Open(Filename:=FilesToOpen(x))

Wb2.Worksheets.Copy _
After:=Wb1.Sheets(Wb1.Sheets.Count)

Wb2.Close False
Next x

'Sheets("Control Sheet").Select
End Sub

Next, turn on the macro recorder, click Data Import External data New
Web Query. Then, type any URL into the address bar. Search around until you
find what you want, click the little yellow arrow (next to the data that you
want to import) and it will turn into a green check box. Finally, click on
the 'Import' button in the lower right hand side of the active window.

I did this and got the code below:
Sub Macro1()

With
ActiveSheet.QueryTables.Add(Connection:="URL;http://finance.yahoo.com", _
Destination:=Range("A1"))
.Name = "finance.yahoo"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

Regards,
Ryan---


--
RyGuy


"SJW_OST" wrote:

I want to have Excel open Windows Explorer to a specific drive location, ie
C:\MyFolder.
I also want Excel to open Internet Explorer to a specific intranet site.
Can either of these actions be done thru Excel VB?

Thanks for any help.


Nayab

Open other applications using code
 
On Aug 6, 9:02*am, SJW_OST wrote:
I want to have Excel open Windows Explorer to a specific drive location, ie
C:\MyFolder.
I also want Excel to open Internet Explorer to a specific intranet site.
Can either of these actions be done thru Excel VB?

Thanks for any help.


All these can be done.

u can use

Sub test()
ActiveWorkbook.FollowHyperlink Address:="H:\", _
NewWindow:=True
End Sub


IF you go to the webpage of say google then just use

Sub test()
ActiveWorkbook.FollowHyperlink Address:="http://www.google.com", _
NewWindow:=True
End Sub


All times are GMT +1. The time now is 01:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com