Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use macro to dynamically add the VBA code and data together
I am working on a project to generate the the report displayed on web or downloaded as excel by using CGI program. The CGI program is responsible to read the text generated dynamically by submit the SQL query (in CGI) to DB and obtain the result. My problem is the report generated is not the excel file but I need to add the VBA code into the generated report. Can this be done?
In addition, I want to open the file in which the file name is unknown until the CGI program pass the filename, how excel macro can accept the file name from CGI program. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use macro to dynamically add the VBA code and data together
To provide more information, here is the vba that I have developed.
Sub TestOpenHyperLink() Dim xOpenedBkName As String Set xWB = ActiveWorkbooks Set xWS = xWB.Worksheets(1) Application.DisplayAlerts = False xWS.Activate Workbooks.OpenText Filename:=Range("A1").Value, origin:=xlWindows, DataType:=xlDelimited, _ tab:=True xOpenedBkName = ActiveWorkbook.Name Workbooks(xOpenedBkName).Activate Sheets(1).Activate Cells.Select Selection.Copy xWB.Activate Sheets.Add after:=Sheets(1) Sheets(2).Select 'xWB.Sheets("Sheet2").Select ActiveSheet.Paste Sheets(2).Name = "Report" Sheets(xWS.Name).Delete Sheets("Report").Activate Range("A1").Select Application.CutCopyMode = False Workbooks(xOpenedBkName).Close Application.CutCopyMode = False Application.DisplayAlerts = True End Sub I fact, how can I pass the filename value from CGI program to replace the Range("A1").value [It contains the URL of the plain text file] within OpenText function in this VBA code. "OpenFile" wrote: I am working on a project to generate the the report displayed on web or downloaded as excel by using CGI program. The CGI program is responsible to read the text generated dynamically by submit the SQL query (in CGI) to DB and obtain the result. My problem is the report generated is not the excel file but I need to add the VBA code into the generated report. Can this be done? In addition, I want to open the file in which the file name is unknown until the CGI program pass the filename, how excel macro can accept the file name from CGI program. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help with Dynamically changing Range in Excel Macro | Excel Discussion (Misc queries) | |||
Dynamically Generated Range using Macro | Excel Worksheet Functions | |||
Dynamically Loading Macro with data | Charts and Charting in Excel | |||
Dynamically Adding Code to Buttons on an existing UserForm | Excel Programming | |||
How to code event for dynamically generated checkboxes | Excel Programming |