Hi
I want to be able to open an existing xls-file to read by pressing a button.
Somebody help me, please!!!
"First timer"
:blush:
Printable View
Hi
I want to be able to open an existing xls-file to read by pressing a button.
Somebody help me, please!!!
"First timer"
:blush:
You want to open an Excel file using a program you are writting in VB or Excel's VBA?
VB
In VB click on Project > References and select "MS Excel x.x Object Library"
Here is some code to get you started.
Need 1 command button, 1 form, 1 textbox.
VB Code:
Option Explicit Private moXl As Excel.Application Private Sub Form_Load() Set moXl = New Excel.Application End Sub Private Sub Command1_Click() On Error GoTo No_Bugs moXl.Workbooks.Open Text1.Text, , False moXl.Visible = True moXl.WindowState = xlMaximized moXl.Application.DisplayAlerts = True ' PROMPT USER TO SAVE UPON EXIT OF EXCELL Exit Sub No_Bugs: MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbInformation End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Set moXl = Nothing End Sub
Thanks! That was great ... and I see now what a ****ty problem there really was!
Though I do have another question
I allso need to be able to open a *.pdf-file
:p
If the workstation has Acrobat Reader then just shell the pdf out.
It will open with the default app for the .pdf extension.
VB Code:
Private Sub Command2_Click() If Text2.Text <> "" Then Shell Text2.Text, vbMaximizedFocus End If End Sub
Still is'nt working!
Could it be because of an referens that is'nt activated?
This is the code
Private Sub Command12_Click()
'The pathname in Text12.text is "C:\Documents and Settings\FRAT\Desktop\merit_pdf.pdf"
If Text12.Text <> "" Then
Shell Text12.Text, vbMaximizedFocus
End If
End Sub
Sorry about that, I forgot to tell you to include the path to Acrobat.
This is my path to Acrobat and pass the parameter of the filename to open.
VB Code:
Option Explicit Private Sub Command1_Click() Dim sFile As String sFile = Text1.Text Shell "D:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe " & sFile, vbMaximizedFocus End Sub
Thanks!
Now everything's perfect!
:wave:
Gald to help.