Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have written a macro that manipulates multiple workbooks. Rather
than require the workbooks to be named a specific name I want to ask the user for the name and use that within my spreadsheet. I used the following command to get the file name from the user: openfilenameA = Application.GetOpenFilename _ (filefilter:="Excel Files (*.xls), *.xls", Title:="Select input datafile from ADP") The only problem with the variable "openfilenameA" was that it contained the full path of the file. My next thought was to open up the file and then use the command: ADPFile = ThisWorkbook.Name My only problem is that once I do this, the value assigned to ADPFile variable is actually the name of my macro spreadsheet that I am running. My process is to have the user open up my macro sheet and then execute the macro from that. This appears to be getting in the way of things. Any ideas on how to fix? Todd |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Todd,
Try ADPFile = ActiveWorkbook.Name after opening the workbook -- HTH Bob Phillips wrote in message ups.com... I have written a macro that manipulates multiple workbooks. Rather than require the workbooks to be named a specific name I want to ask the user for the name and use that within my spreadsheet. I used the following command to get the file name from the user: openfilenameA = Application.GetOpenFilename _ (filefilter:="Excel Files (*.xls), *.xls", Title:="Select input datafile from ADP") The only problem with the variable "openfilenameA" was that it contained the full path of the file. My next thought was to open up the file and then use the command: ADPFile = ThisWorkbook.Name My only problem is that once I do this, the value assigned to ADPFile variable is actually the name of my macro spreadsheet that I am running. My process is to have the user open up my macro sheet and then execute the macro from that. This appears to be getting in the way of things. Any ideas on how to fix? Todd |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you just need to get the filename from a path you could use:
Dim openfilefullnameA As String Dim openfilenameA As String openfilefullnameA = Application.GetOpenFilename _ (filefilter:="Excel Files (*.xls), *.xls", Title:="Select input datafile from ADP") openfilenameA = LCase$(Mid$(openfilefullnameA, InStrRev(openfilefullnameA, "\") + 1)) wrote in message ups.com... I have written a macro that manipulates multiple workbooks. Rather than require the workbooks to be named a specific name I want to ask the user for the name and use that within my spreadsheet. I used the following command to get the file name from the user: openfilenameA = Application.GetOpenFilename _ (filefilter:="Excel Files (*.xls), *.xls", Title:="Select input datafile from ADP") The only problem with the variable "openfilenameA" was that it contained the full path of the file. My next thought was to open up the file and then use the command: ADPFile = ThisWorkbook.Name My only problem is that once I do this, the value assigned to ADPFile variable is actually the name of my macro spreadsheet that I am running. My process is to have the user open up my macro sheet and then execute the macro from that. This appears to be getting in the way of things. Any ideas on how to fix? Todd |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ThisWorkbook of personal.xls | Excel Discussion (Misc queries) | |||
ThisWorkbook | Excel Programming | |||
ThisWorkbook.Protect | Excel Programming | |||
ThisWorkbook.FullName | Excel Programming | |||
How to use: ThisWorkbook module | Excel Programming |