vzachin
11-22-2006, 05:13 AM
hi,
I have a code that opens a .csv file from the company's intranet.
Data is then copied & pasted from the opened file to the workbook that generated the macro. And then the file is closed.
The file that is opened is referenced by the EndUser that generates the report. e.g. USERNAME.REPORTNAME.csv.
I can run this macro without a problem because I am the one generating the request. However,if somebody else ran this report, they cannot open their own report because the link to the file is hardcoded with my UserName in the coding.
Is there any way to have the EndUser input their USERNAME and then somehow link this USERNAME to the file that gets opened?
Workbooks.Open Filename:= _
"http://xxxxxxxxxx.xxxxxx.com/xxxxxx/xxxxxx/xxxxxx/USERNAME.REPORTNAME.CSV"
ActiveWindow.Visible = True
Application.DisplayAlerts = False
'=============
Windows("USERNAME.REPORTNAME.CSV").Activate
Cells.Select
Selection.Copy
Windows("ORIGINALREPORTNAME.xls").Activate
Sheets("Sheet1").Select
Range("A1").Select
ActiveSheet.Paste
Windows("USERNAME.REPORTNAME.CSV").Close
thanks
zach
I have a code that opens a .csv file from the company's intranet.
Data is then copied & pasted from the opened file to the workbook that generated the macro. And then the file is closed.
The file that is opened is referenced by the EndUser that generates the report. e.g. USERNAME.REPORTNAME.csv.
I can run this macro without a problem because I am the one generating the request. However,if somebody else ran this report, they cannot open their own report because the link to the file is hardcoded with my UserName in the coding.
Is there any way to have the EndUser input their USERNAME and then somehow link this USERNAME to the file that gets opened?
Workbooks.Open Filename:= _
"http://xxxxxxxxxx.xxxxxx.com/xxxxxx/xxxxxx/xxxxxx/USERNAME.REPORTNAME.CSV"
ActiveWindow.Visible = True
Application.DisplayAlerts = False
'=============
Windows("USERNAME.REPORTNAME.CSV").Activate
Cells.Select
Selection.Copy
Windows("ORIGINALREPORTNAME.xls").Activate
Sheets("Sheet1").Select
Range("A1").Select
ActiveSheet.Paste
Windows("USERNAME.REPORTNAME.CSV").Close
thanks
zach