Hi Expert,
I was new on VB scrip, my understanding on the below function use are not that good.
I have one excel file (A) that has macro button to open up another excel file (B) at the same subfolder location with the below function.
========================
==================================Function MyDocuments() As String Dim objFSO As Object Dim objShell As Object Dim objFolder As Object Dim objFolderItem As Object Const MY_DOCUMENTS = &H5& Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(MY_DOCUMENTS) Set objFolderItem = objFolder.Self MyDocuments = objFolderItem.Path End Function Function Open_File() Dim Path As String Path = MyDocuments() & "\Sales Tools\Quotation Form.xls" Set Quotation = Workbooks.Add(Path).ActiveSheet Set Calculation = ThisWorkbook.ActiveSheet End Function
Query 1 : What does it mean on "Const MY_DOCUMENTS = &H5&" ?
Query 2 : is that possible to change the path to be more specific as fixed it at c drive\ subfolder? What changes i should make on the function above?
Query 3 : is that possble to change the path to flexible where user paste the folder at desktop or other drive on above statement?
Query 4 : I keep having problem on running above function which doesn't recognised the excel file (B) to be open. How do I refresh the path variable?
query 5 : For excel file A & B are sitting at the same subfolder, how do i get the macro button to automatic call search file from the same subfolder and with the filename as "Quotation Form.xls"
hope to hear the expert.
Thanks
Regards,
Anney Png
Bookmarks