问题描述
SubGeneration()''GenerationMacro''快捷键:Ctrl+Shift+GDimiRow,iCol,iRntDimCurRootDimxFileName,xID,xPath,xTDir,xRNTxFileName=1xID=9xPath=10xTDir=11xRNT=12CurRoot="D:MSDNLib"ForiRow=2To3000IfSheet1.Cells(iRow,xID)=""ThenExitForEndIfiRnt=GenFile(Sheet1.Cells(iRow,xFileName),CurRoot,"Result"&Sheet1.Cells(iRow,xPath),Sheet1.Cells(iRow,11))Sheet1.Cells(iRow,xRNT)=iRntNextMsgBox"OO"'EndSubFunctionGenFile(sFile,sRoot,sPath,sContent)AsLongDimsTarget,sSourcesTarget=CreateDir(sRoot,sPath)&""&sFileSource=sRoot&""&sPath&""&sFileIfInStr(1,".xml",sFile)<=0ThenGenFile=-1ExitFunctionEndIfDimxmlG1,xmlG2xmlG1=xmlG1&"<?xmlversion=""1.0""encoding=""utf-8""?>"&vbCrLfxmlG1=xmlG1&"<contentxmlns=""http://www.microsoft.com/MSCOM/MNP2/Schemas""type=""MNP2.GenericHome"">"&vbCrLfxmlG1=xmlG1&"<head>"&vbCrLfxmlG1=xmlG1&"<metaname=""description""content=""MSDN中文网站""/>"&vbCrLfxmlG1=xmlG1&"<metaname=""keywords""content=""MSDN中文网站""/>"&vbCrLfxmlG1=xmlG1&""&vbCrLfxmlG1=xmlG1&"</head>"&vbCrLfxmlG1=xmlG1&"<bodylayout=""fullWidthTop""fixedWidth=""true"">"&vbCrLfxmlG1=xmlG1&"<pageTitle>MSDN中文网站</pageTitle>"&vbCrLfxmlG1=xmlG1&"<topContent>"&vbCrLfxmlG1=xmlG1&"<xhtml>"&vbCrLfxmlG1=xmlG1&"<SCRIPTLANGUAGE=""JavaScript"">"&vbCrLfxmlG1=xmlG1&"window.location="""&sContent&""";"&vbCrLfxmlG1=xmlG1&"</SCRIPT>"&vbCrLfxmlG1=xmlG1&"</xhtml>"&vbCrLfxmlG1=xmlG1&"</topContent>"&vbCrLfxmlG1=xmlG1&"</body>"&vbCrLfxmlG1=xmlG1&"</content>"'Setf=fs.createtextfile(sTarget,True,"UTF-8")'f.writelinexmlG1'f.CloseSetobjStream=CreateObject("ADODB.Stream")WithobjStream.Open.Charset="utf-8".Position=objStream.Size.WriteText=xmlG1.SaveToFilesTarget,2.CloseEndWithSetobjStream=NothingGenFile=1EndFunctionFunctionCreateDir(sRoot,sPath)AsStringDimfs,fSetfs=CreateObject("Scripting.FileSystemObject")Iffs.folderexists(sRoot&""&sPath)=TrueThenCreateDir=sRoot&""&sPathExitFunctionEndIfDimaFoldersDimiLevel,sLC,sCuraFolders=Split(sPath,"")'iLevel=UBound(aFolders)sCur=""ForiLevel=0ToUBound(aFolders)sCur=sCur&""&aFolders(iLevel)Iffs.folderexists(sRoot&sCur)=FalseThenfs.createfolder(sRoot&sCur)EndIfNextCreateDir=sRoot&""&sPathEndFunction
解决方案
解决方案二:
大概说一下也行呀,谢谢...