Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Dynamically changing Range in Excel Macro runsrealfast Excel Discussion (Misc queries) 4 July 16th 07 10:44 PM
Dynamically Generated Range using Macro [email protected] Excel Worksheet Functions 2 July 15th 06 08:12 AM
Dynamically Loading Macro with data Fred Charts and Charting in Excel 0 July 6th 06 02:21 AM
Dynamically Adding Code to Buttons on an existing UserForm Peter Street Excel Programming 2 September 29th 03 09:54 AM
How to code event for dynamically generated checkboxes Chong Moua Excel Programming 0 July 9th 03 08:18 PM


All times are GMT +1. The time now is 11:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"