?
Solved

Open .xls with viewer

Posted on 2006-04-05
4
Medium Priority
?
682 Views
Last Modified: 2008-01-09
I have a program that will open .xls files with the full version of excel. How can i get it to open the fiels with excel viewer. This is with Visual Basic 6
0
Comment
Question by:Kirius
  • 2
4 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 16384636
if you goto Project > Components you can add the Microsoft Internet Controls which will give you the Webbrowser control. If you add that control you can view excel files using something like this:


Private Sub Command1_Click()
WebBrowser1.Navigate2 "C:\Test.xls"
End Sub
0
 
LVL 1

Author Comment

by:Kirius
ID: 16384685
Well what I have is a program where you can choose what .xls you want to view. Each .xls has about 10-50 sheets in it. I can open it fine on workstations with full versions of office. But some workstations, I don't want to use Internet Explorer or Full version excel because they don't have it on those. But to open it with Excel Viewer.
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 300 total points
ID: 16384828
if you are using shellexecute api it will launch xls files with the default app which would be the full version of excel if it exists. To launch the viewer you will need to have it's location:

Private Sub Command1_Click()
Dim ExcelFile as String
ExcelFile =  Chr(34) & "C:\Test.xls" & Chr(34)

Shell Chr(34) & "C:\Program Files\Microsoft Office\OFFICE11\XLVIEW.EXE" & Chr(34) & " " & ExcelFile, vbNormalFocus

End Sub
0
 

Expert Comment

by:ByteWolf
ID: 16384911
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

Private Sub Command1_Click()
Dim xlsPath, xlsVwr As String
Dim retVal As Long

'Path of excelviewer can be extracted out of the registry.
'
'HKEY_CLASSES_ROOT\Applications\xlview.exe\shell\open\command
'@="C:\\PROGRA~1\\MICROS~3\\OFFICE11\\XLVIEW.EXE /e"
xlsVwr = "C:\PROGRA~1\MICROS~3\OFFICE11\XLVIEW.EXE"

'Path of the XLS File
xlsPath = App.Path & "\map1.xls"

'Run the Viewer
retVal = ShellExecute(Me.hwnd, "Open", xlsVwr, xlsPath, "", 1)


End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question