Home > Software engineering >  Excelbook SaveAs save the file
Excelbook SaveAs save the file

Time:11-06

The Set ExcelApp=CreateObject (" Excel. Application ")
ExcelApp. Application. The Visible=False
'ExcelApp. WorkBooks. Open (" e:/data. XLS ")
The Set ExcelBook=ExcelApp. Workbooks. Add
ExcelBook. WorkSheets (1) cells (1, 1). The value="https://bbs.csdn.net/topics/SN"
ExcelBook. WorkSheets (1) cells (1, 2). Value="https://bbs.csdn.net/topics/SN"
ExcelBook. WorkSheets (1) cells (1, 3). Value="https://bbs.csdn.net/topics/SN"
ExcelBook. WorkSheets (1) cells (1, 4). Value="https://bbs.csdn.net/topics/SN"
ExcelBook. WorkSheets (1) cells (1, 5). The value="https://bbs.csdn.net/topics/SN"
ExcelBook. WorkSheets (1) cells (1, 6). Value="https://bbs.csdn.net/topics/SN"
ExcelBook. WorkSheets (1) cells (1, 7). Value="https://bbs.csdn.net/topics/SN"
ExcelBook. WorkSheets (1) cells (1, 8) value="https://bbs.csdn.net/topics/SN"
ExcelBook. WorkSheets (1) cells (1, 9). Value="https://bbs.csdn.net/topics/SN"
ExcelBook. WorkSheets (1) cells (1, 10). Value="https://bbs.csdn.net/topics/SN"
CNT=2
Eof
the do while not rs.ExcelBook. WorkSheets (1) cells (CNT, 1). value=https://bbs.csdn.net/topics/rs.fields (" SN "). The value
ExcelBook. WorkSheets (1) cells (CNT, 2) value=https://bbs.csdn.net/topics/rs.fields (" PN "). The value
ExcelBook. WorkSheets (1) cells (CNT, 3) value=https://bbs.csdn.net/topics/rs.fields (" TEST_Temp "). The value
ExcelBook. WorkSheets (1) cells (CNT, 4). value=https://bbs.csdn.net/topics/rs.fields (" DDM_BIAS "). The value
ExcelBook. WorkSheets (1) cells (CNT, 5). value=https://bbs.csdn.net/topics/rs.fields (" DDM_TXPWR "). The value
ExcelBook. WorkSheets (1) cells (CNT, 6). value=https://bbs.csdn.net/topics/rs.fields (" TX_PWR "). The value
ExcelBook. WorkSheets (1) cells (CNT, 7). value=https://bbs.csdn.net/topics/rs.fields (" TX_ER "). The value
ExcelBook. WorkSheets (1) cells (CNT, 8) value=https://bbs.csdn.net/topics/rs.fields (" RX_SEN "). The value
ExcelBook. WorkSheets (1) cells (CNT, 9). value=https://bbs.csdn.net/topics/rs.fields (" LOS_AST "). The value
ExcelBook. WorkSheets (1) cells (CNT, 10) value=https://bbs.csdn.net/topics/rs.fields (" LOS_DAST "). The value
Rs. Movenext
CNT=cint (CNT) + 1
Loop
Excelbook. SaveAs ("../dataExcel/order. XLS ")
Wscript. Sleep 3000

ExcelApp. Application. After the Quit 'export exit Excel
The Set ExcelApp logout Excel object
=Nothing '
Excelbook. SaveAs ("../dataExcel/order. XLS ")
Don't complain, but did not generate the corresponding files
Start at the beginning of bosses know, please

CodePudding user response:


Path problem. I know change the absolute path can be generated.

CodePudding user response:

Since "no error", that is surely the files are generated,


I also agree with the upstairs, you use "relative path", don't know "relative" go!
With "absolute path" seen known a try!
Or, you can after the "save" operation, MsgBox once ExcelBook. Path (probably is this attribute )
To see it go,

CodePudding user response:

Not don't save, but don't know where have saved,

CodePudding user response:

Chewinggum
reference 3 floor response:
is not can't save, but don't know where have saved,


At the next higher level dataExcel directory?

CodePudding user response:

Path problem, try the following:

Excelbook. SaveAs (App. Path & amp; "DataExcel \ order. XLS")
Or
Excelbook. SaveAs (App. Path & amp; "The order. XLS")

CodePudding user response:

Slash the??????

CodePudding user response:

Want the superior directory, you can try to use the
Dim tempstr
Dim newpath as string
Tempstr=split (App) Path, "")
For I=0 to ubound (tempstr) - 1
Newpath=newpath & amp; "" & amp; Tempstr (I)
Next I
Newpath=right (newpath, len (newpath) - 1)
Newpath superior directory is the current program!

CodePudding user response:

refer to 7th floor kinkolau response:
want superior directory, you can try to use the
Dim tempstr
Dim newpath as string
Tempstr=split (App) Path, "")
For I=0 to ubound (tempstr) - 1
Newpath=newpath & amp; "" & amp; Tempstr (I)
Next I
Newpath=right (newpath, len (newpath) - 1)
Newpath superior directory is the current program!

Also can use of fso getparentfoldername function.

CodePudding user response:

Save the code is not complete, there are other parameters: g_Newbook. SaveAs (COleVariant (SaveExcelPath), covOptional,
CovOptional, covOptional,
CovOptional, covOptional, (long) 0, covOptional, covOptional, covOptional,
CovOptional, covOptional);
  •  Tags:  
  • VBA
  • Related