Добро пожаловать в форум, Guest  >>   Войти | Регистрация | Поиск | Правила | В избранное | Подписаться
Все форумы / Microsoft SQL Server Новый топик    Ответить
 EXCEL-MSSQL  [new]
guest12
Guest
Vsem dobrii den.

Proshu proshenia - tema izbitaia, no ne polchaetsia chto-to u menia.

Ispolzuu DTS (ActiveX) dlia zagruzki dati iz EXCELa v MSSQL. EXCEL "Protected" tak vot mne nuzno sdelat "Unprotect" a chto-to ne pochaetsi. Ispolzuu sript:
Nuzno li stavit "password" kogda delaesh "Unprotect"?
'*************************************************************
' Visual Basic ActiveX Script
'*************************************************************FFunction Main()
Set xls = CreateObject("Excel.Application")
xls.Visible = False
xls.Workbooks.Open "C:\sales2.XLS"
Set book = xls.Workbooks(1)

For Each foo In book.Worksheets
foo.Activate
foo.Unprotect

Next
book.Close True
xls.Quit
Main = DTSTaskExecResult_Success
End Function
9 мар 04, 01:38    [567444]     Ответить | Цитировать Сообщить модератору
 Re: EXCEL-MSSQL  [new]
guest12
Guest
Pomogite razobratsia.

Chto znachit eta oshibka?(krasnim)

This action cannot be completed because the
“Microsoft Excel – test.xls” program is not responding.
Choose “Switch To” and correct the problem


Zapuskau script, privedennii nize i ona nachinaet vidavat etu oshibku.
Esli odin file, to vse delaet normalno, a vot esli neskolko to na kazdii "WorkSheet" prosit "Switch To"

'********************************************************************
' Visual Basic ActiveX Script
'********************************************************************
Function Main()
Dim objFSO
Dim objFolder
Dim objFiles

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Doc\test")
Set objFiles = objFolder.Files
Set xls = CreateObject("Excel.Application")
If objFiles.count >0 then
For Each item in objFiles
MsgBox("Found File - " + item.name + " Path to file - " + item.path + " Type of File - " + item.Type)

xls.Visible =True
xls.Workbooks.Open item.path
Set book = xls.Workbooks(1)

For Each foo In book.Worksheets
foo.Activate
foo.Unprotect "friday"
foo.Range("A1") = "sel"
Next
book.Save
book.Close True
xls.Quit

Next
Main = DTSTaskExecResult_Success
else
Msgbox("No Files !!! like STOP")
Main = DTSTaskExecResult_Failure
End if
Set objFiles = nothing
Set objFolder = nothing
Set objFSO = nothing
Main = DTSTaskExecResult_Success
End Function
11 мар 04, 08:48    [571571]     Ответить | Цитировать Сообщить модератору
Все форумы / Microsoft SQL Server Ответить