ClimoC
Well-known Member
- Joined
- Aug 21, 2009
- Messages
- 584
Hi all
Cannot see why this gives an 'Automation Error'.
Thought at first it may be because the workbook being opened is a csv, but further tests have shown that to be rubbish.
All I want REALLY, is to obtain the filepath and filename from a cell (@ Sheets("Multipass").Range("B8").value, set by the FileOpenDialog string return) so that I can use the ADO to open the csv into a recordset directly.
My current method of grabbing the string for the Path is only doable when I open the workbook. I don't want to open it TWICE to get the name and path.. ideally don't want to do it at all!
Stepping through it, 'TBB' is never set, but the workbook DOES open. xWBSource gets set though, but no second version of the csv/xlsx gets opened.
This should be like water to a duck for me but I think I'm missing one of those little bits of info you don't know til you know about proper or allowable syntaxes/orders of things....
Any ideas?
Thanks
Cannot see why this gives an 'Automation Error'.
Thought at first it may be because the workbook being opened is a csv, but further tests have shown that to be rubbish.
All I want REALLY, is to obtain the filepath and filename from a cell (@ Sheets("Multipass").Range("B8").value, set by the FileOpenDialog string return) so that I can use the ADO to open the csv into a recordset directly.
My current method of grabbing the string for the Path is only doable when I open the workbook. I don't want to open it TWICE to get the name and path.. ideally don't want to do it at all!
Stepping through it, 'TBB' is never set, but the workbook DOES open. xWBSource gets set though, but no second version of the csv/xlsx gets opened.
This should be like water to a duck for me but I think I'm missing one of those little bits of info you don't know til you know about proper or allowable syntaxes/orders of things....
Code:
Global RS As Recordset, CS As Worksheet, cstrw As Long
Public Function Multi()
Dim chans As New Scripting.dictionary, iCh As Variant, ChK As Variant
Dim xWb As String, xWbSource As String, TBB As Workbook, xWb2 As String
xWb = ThisWorkbook.Sheets("Multipass").Range("B8").Value
Set TBB = Workbooks.Open(xWb)
xWbSource = Workbooks.Open(xWb).Path
xWb2 = TBB.name
xWb = Right(xWb, InStrRev(xWb, "\", , vbTextCompare))
ThisWorkbook.Activate
ImportToRecSet xWb, xWbSource
TB.Close
Any ideas?
Thanks