visualbasic
asked on
Modify and Saving an excel file as ? in within VB
I want to open an excel file ,modify one cell and then save as
any of the following types.
Microsoft Excel 97 && 5.0/95 Workbook
Microsoft Excel 5.0/95 Workbook
Microsoft Excel 4.0 Workbook
Microsoft Excel 3.0 Worksheet
Microsoft Excel Workbook
WK4(1-2-3)
WK3(1-2-3)
WK1(1-2-3)
WKs(1-2-3)
Text (Tab Delimited)
How can I do this?
any of the following types.
Microsoft Excel 97 && 5.0/95 Workbook
Microsoft Excel 5.0/95 Workbook
Microsoft Excel 4.0 Workbook
Microsoft Excel 3.0 Worksheet
Microsoft Excel Workbook
WK4(1-2-3)
WK3(1-2-3)
WK1(1-2-3)
WKs(1-2-3)
Text (Tab Delimited)
How can I do this?
The way your question is asked it seems you can do all of what you are asking right from excel without VB. At what point does VB do anything. We need some more specifics.
Try yourself
Open new excel and click on tools, macro and then record new macro.
Save your excel by choosing your save as.
stop the macro and press Alt-
F11, you should see the code on modules folder-module1
for example
ActiveWorkbook.SaveAs Filename:="C:\temp\Book1.x ls" _
, FileFormat:=xlExcel2, Password:="", CreateBackup:=False
Open new excel and click on tools, macro and then record new macro.
Save your excel by choosing your save as.
stop the macro and press Alt-
F11, you should see the code on modules folder-module1
for example
ActiveWorkbook.SaveAs Filename:="C:\temp\Book1.x
, FileFormat:=xlExcel2, Password:="", CreateBackup:=False
ASKER
I want to create a stock list from within vb.the user selects a Sheet type
and the wizard then creates this sheet.
I am using this sheet for a Stock count on a Palmtop.If the user only has works then he can create a works sheet...
When the count is complete then the user imports the count data from the sheet.
and the wizard then creates this sheet.
I am using this sheet for a Stock count on a Palmtop.If the user only has works then he can create a works sheet...
When the count is complete then the user imports the count data from the sheet.
xlAddInxlCSVxlCSVMacxlCSVM SDOSxlCSVW indowsxlDB F2xlDBF3xl DBF4xlDIFx lExcel2xlE xcel2FarEa stxlExcel3 xlExcel4xl Excel5xlEx cel4Workbo okxlIntlAd dInxlIntlM acroxlWork bookNormal xlSYLK xlTemplatexlCurrentPlatfor mTextxlTex tMacxlText MSDOSxlTex tPrinterxl TextWindow sxlWJ2WD1x lWK1xlWK1A LLxlWK1FMT xlWK3xlWK4 xlWK3FM3xl WKSxlWorks 2FarEastxl WQ1xlWJ3xl WJ3FJ3
Hi VB,
Try this:
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Set xlApp=CreateObject("Excel. Applicatio n")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open "C:\MyDir\MyFile.xls"
xlBook.Sheets("Sheet1").Ce lls(1,1) = "Hello"
xlBook.SaveAs Filename:="text.xls",FileF ormat:=xlW orkbookNor mal 'see other constants below
xlBook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
Constant you should use
xlExcel9795 Microsoft Excel 97
xlExcel5 Microsoft Excel 5.0/95 Workbook
xlExcel4 Microsoft Excel 4.0 Workbook
xlExcel3 Microsoft Excel 3.0 Worksheet
xlNormal Microsoft Excel Workbook
xlWK4 WK4(1-2-3)
xlWK3 WK3(1-2-3)
xlWK1 WK1(1-2-3)
xlWKs WKs(1-2-3)
xlText Text (Tab Delimited)
Calacuccia
Hi VB,
Try this:
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Set xlApp=CreateObject("Excel.
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open "C:\MyDir\MyFile.xls"
xlBook.Sheets("Sheet1").Ce
xlBook.SaveAs Filename:="text.xls",FileF
xlBook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
Constant you should use
xlExcel9795 Microsoft Excel 97
xlExcel5 Microsoft Excel 5.0/95 Workbook
xlExcel4 Microsoft Excel 4.0 Workbook
xlExcel3 Microsoft Excel 3.0 Worksheet
xlNormal Microsoft Excel Workbook
xlWK4 WK4(1-2-3)
xlWK3 WK3(1-2-3)
xlWK1 WK1(1-2-3)
xlWKs WKs(1-2-3)
xlText Text (Tab Delimited)
Calacuccia
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.