Hi all, I need to convert someone else's Access VBA so that it opens the first sheet in an Excel spreadsheet, and not the named one.
The existing code:
I've tried replace xTable (string) with 1 (integer) with no success.
Next I tried (and various simialr approaches!) to get the sheet name to use in the original, with no joy. :
I'm sure this is simple, but I can't find the solution anywhere!
Ta.
The existing code:
Code:
Set ltb = db.CreateTableDef(strLink_name)
ltb.Connect = xConnection_string
ltb.SourceTableName = xTable ' e.g. sheet1
I've tried replace xTable (string) with 1 (integer) with no success.
Next I tried (and various simialr approaches!) to get the sheet name to use in the original, with no joy. :
Code:
Set objXL = New Excel.Application
With objXL
Set objWkb = .Workbooks.Open(aFileName)
On Error Resume Next
objWkb.Worksheets(1).Activate
Set objSht = objWkb.ActiveSheet
If Not Err.Number = 0 Then
WSName = objSht.Name
End If
Err.Clear
I'm sure this is simple, but I can't find the solution anywhere!
Ta.