Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Installing object libraries from later versions of office 1

Status
Not open for further replies.

bodmin

Technical User
Apr 1, 2004
98
GB
Hi

I have developed a bit of macro code for excel that uses the filedialog object class.

This code was developed on a machine with office XP and therefore the Office Object library 10.0 where this class is available.

I have now transferred this code to the machine that is going to be using this for everyday activity and have found the problem that they have an earlier version of office which does not have the filedialog class available.

What I would love to know is whether there is a way to install later object libraries (or relevant sections of that library) on a machine with an earlier version of office or are my only options to either update the office package on the machine or find a different method to code with?

Also if there is no way of doing this can someone suggest an equivalent method to filedialog in the earlier office object libraries?
 
I don't believe those object libraries are redistributable so at the very least, there would be legal issues, if not technical ones. So, yes, I think your only options are upgrading or selecting a different approach.

If you explain what your macro currently does, someone can probably point to an alternative strategy.


Regards,
Mike

 
Hi Mike,

my code is as follows:

Dim OpenFile As FileDialog

'Turn off screen flashing
Application.ScreenUpdating = False
'ActiveWorkbook.ActiveSheet.Visible = False

Set OpenFile = Application.FileDialog(msoFileDialogFilePicker)
OpenFile.AllowMultiSelect = False
'OpenFile.Show
If OpenFile.Show = -1 Then
strXLWorkBook_Location = OpenFile.SelectedItems(1)
Else
MsgBox ("Cancelled by user request")
ActiveWorkbook.Close
End If

What I am trying to do is display a dialog box that allows the user to browse to a file and select this, rather than making them type in the path to the file in an input box.

Any ideas about how I could do this in Office 97/2000?

thanks in advance
 
Sub Macro1()

Dim MyFileName As Variant
Dim OrigDir As String

OrigDir$ = CurDir$

On Error Resume Next
'by default opens over My Docs
ChDir RequiredDir
On Error GoTo 0

'open a file selection dialog over the required folder
MyFileName = Application.GetOpenFilename("Excel Files (*.xls), *.xls", 1, "Load file")

'myfileName will be false if the file dialog is abandoned
If MyFileName <> False Then
'a file was selected so load it into a new workbook
Application.Workbooks.Open MyFileName
End If

ChDir OrigDir$

End Sub
 
bodmin,

Any feedback on HughLerwill's suggestion, which should do what you want?


HughLerwill said:
'myfileName will be false if the file dialog is abandoned
Ah, the cruelty.


Regards,
Mike
 
Hi guys,

That appears to have found away round my problem thank you very much for your help.

Have only just got a chance to put code in place and test but appears to sort all of the issues I was having.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top