indyman
09-06-2014, 12:11 PM
I am trying to read data from an Excel workbook into Word document. I have Office 2010 and WIn7. Here is the macro I have started in the Word document. I want to have the GetOpenFilename have the default directory of the active document be the starting directory of the File Open dialogue box. I have searched for hours for a solution, but none of them work. Every time it opens to the Libraries -> Documents folder, even though the msgbox clearly shows the strDefaultPath variable being set to the desired path. The desired path is on my G Drive. This should be simple, sowhat am I missing"
Sub ReadExcel()
Set appExcel = CreateObject("Excel.Application")
Dim Data_File As Variant
strDefaultPath = ActiveDocument.Path
ChDrive Left(strDefaultPath, 1)
ChDir strDefaultPath
MsgBox strDefaultPath
Data_File = appExcel.GetOpenFilename("Excel files (*.xlsx), *.xlsx")
End Sub
Any help is greatly appreciated.
Sub ReadExcel()
Set appExcel = CreateObject("Excel.Application")
Dim Data_File As Variant
strDefaultPath = ActiveDocument.Path
ChDrive Left(strDefaultPath, 1)
ChDir strDefaultPath
MsgBox strDefaultPath
Data_File = appExcel.GetOpenFilename("Excel files (*.xlsx), *.xlsx")
End Sub
Any help is greatly appreciated.