I have a form that launches queries and one of them dumps 3 separate queries' data to separate tabs of one excel workbook. Previously I was having VBA create the workbook at the root C:\ drive, but recently our IT folks have prevented any users from writing directly to the C:\ drive. This problem is further compounded by the fact that I have users using 2 different computer networks, on one the user profiles are in the C:\ drive, but on the other they are in the D:\ drive (which the first network does not have). Below is the working VBA code I was using to export, format, and open the data when I was able to have users write to the C:\ drive:
If Me.QUERYLIST.Value = "Manning Detail" Then
Me.lblBuildingReport.Visible = True
Me.Repaint
DoCmd.Close acQuery, "X MANNING DETAIL"
DoCmd.Close acQuery, "Y MANNING DETAIL"
DoCmd.Close acQuery, "Z MANNING DETAIL"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "X MANNING DETAIL", "C:\Manning Detail.xlsx", , "XMANNING"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Y MANNING DETAIL", "C:\Manning Detail.xlsx", , "YMANNING"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Z MANNING DETAIL", "C:\Manning Detail.xlsx", , "ZMANNING"
FormatExcelBasic "C:\Manning Detail.xlsx", "XMANNING"
FormatExcelBasic "C:\Manning Detail.xlsx", "YMANNING"
FormatExcelBasic "C:\Manning Detail.xlsx", "ZMANNING"
Application.FollowHyperlink "C:\Manning Detail.xlsx"
Me.lblBuildingReport.Visible = False
Me.Repaint
End If
I have been able to get the queries to write and format by changing the instances of "C:\Manning Detail.xlsx" to just "Manning Detail.xlsx" but the command to open the workbook (Application.FollowHyperlink) does not work without a path to the file. Is there a way to point to the workbook in the "My Documents" folder that works regardless of the Drive on which it resides? Is there something another command I should be using?
Thanks in advance.
