| | |
Saving excel sheet with few column names present as file name
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2007
Posts: 28
Reputation:
Solved Threads: 0
Hi All,
I am creating and saving the excel sheet at runtime(it is a copy of report generated in flexgrid). I need to add some of the column names in the excel sheet name while saving. e.g. Excel sheet should be saved as Report_Nid_Status_RBAC_Status_Today'sDate.
Nid_Status and RBAC_Status are column names in the sheet. Columns can vary and so the sheet name according to the columns. How I can save an excel sheet like this?
Regards,
Shilpa
I am creating and saving the excel sheet at runtime(it is a copy of report generated in flexgrid). I need to add some of the column names in the excel sheet name while saving. e.g. Excel sheet should be saved as Report_Nid_Status_RBAC_Status_Today'sDate.
Nid_Status and RBAC_Status are column names in the sheet. Columns can vary and so the sheet name according to the columns. How I can save an excel sheet like this?
Regards,
Shilpa
Last edited by Shilpa Jain; Jul 11th, 2008 at 1:19 am.
To save the excel workbook with vb you need to use next line:
I hope this was helpfull for you.
gr
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
xl.activeworkbook.saveas "C:\... " & var1 & "text" & var2 & var3 ... ".xls"
I hope this was helpfull for you.
gr
•
•
Join Date: Apr 2007
Posts: 28
Reputation:
Solved Threads: 0
Thanks for replying. But , I am unable to get what you are trying to say. As per my understanding, this can be used only when the names are fixed. Correct me if I am wrong.
I have 3 columns in my report viz. NID_Status,ISD_Status,RBAC_status. Report can containg any of these 3 fields or a combination of them. For example, It can be
As of now, I am saving the file in Report_Date format as:
Please help.
Regards,
Shilpa
I have 3 columns in my report viz. NID_Status,ISD_Status,RBAC_status. Report can containg any of these 3 fields or a combination of them. For example, It can be
Report_NID_Status_ISD_Status_TodaysDate if it contains only NID and Rbac columns or it can be Report_NID_Status_TodaysDate if only NID column is present or Report_NID_Status_ISD_Status_RBCA_Status_TodaysDate if all 3 columns are present in the report. The report name will vary depending which all columns are present in it. How do I incorporate these variable names in the report.As of now, I am saving the file in Report_Date format as:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
ApExcel.ActiveWorkbook.SaveAs FileName:="C:\Documents and Settings\All Users\Desktop\Report_" & _ Format(Now(), "dd-mm-yyyy_hhmm") & ".xls", _ CreateBackup:=False
Please help.
Regards,
Shilpa
•
•
Join Date: Apr 2007
Posts: 28
Reputation:
Solved Threads: 0
You have almost understand my question. I have atleast 5 columns in my report at a time. One of them would be like NID_Status. I only need to insert the *_Status column in my report name. Others should not be there.
I am attaching few samples of the report. It is named in the format of Report_Date_Time. It should be Report_*_Status_*_Status_Date_Time.The columns containing _Status only have to be present in the report name.
I hope you have understood my problem and will help me.
Regards,
Shilpa
I am attaching few samples of the report. It is named in the format of Report_Date_Time. It should be Report_*_Status_*_Status_Date_Time.The columns containing _Status only have to be present in the report name.
I hope you have understood my problem and will help me.
Regards,
Shilpa
K. I think I understand your problem.
I can not read you attachment for some reason. did you make that in excel???
because when I opend it with excel I get an error that the file was not created with excel.
I will try to explain
I asume your collum titels are in row 1 collum 1 to 5 ???
then you open your workbook or make a new and fil it in.
then, when you want to save the file, you use next code.
I hope this solve you problem or was a little bit use full to solve you problem.
gr
I can not read you attachment for some reason. did you make that in excel???
because when I opend it with excel I get an error that the file was not created with excel.
I will try to explain
I asume your collum titels are in row 1 collum 1 to 5 ???
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim var1, var2, var3, var4, var5 Dim ApExcel As Excel.Application Set ApExcel = New Excel.Application
then you open your workbook or make a new and fil it in.
then, when you want to save the file, you use next code.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Windows("name of your excel sheet.xls").Activate 'some times nessesary if cells(1,1) <> "" then var1 = cells(1,1) & "_Status_" end if if cells(1,2) <> "" then var2=cells(1,2) & "_Status_" end if if cells(1,3) <> "" then var3=cells(1,3) & "_Status_" end if if cells(1,4) <> "" then var4=cells(1,4) & "_Status_" end if if cells(1,5) <> "" then var5=cells(1,5) & "_Status_" end if ApExcel.ActiveWorkbook.SaveAs FileName:="C:\Documents and Settings\All Users\Desktop\Report_" & var1 & var2 & var3 & var4 & var5 & Format(Now(), "dd-mm-yyyy_hhmm") & ".xls"
I hope this solve you problem or was a little bit use full to solve you problem.
gr
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Help! to create a table in Oracle with dynamically assigned name from VB 6.0.
- Next Thread: How to add row and col into MsFlexGrid1
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





