In the code below, I'm trying to automate SmartView recovery in several worksheets. This code works properly, as long as I make a connection before starting loop. Inside the loop, I want to use HypConnect to use the connection - but it provides a code of 100,000 and does not connect. When I test some situation variables, I think the connection exists, but the sheet is not connected.
I have copied the entire smartview.bas file into another module in another workbook.
At this point when I connect to Hype Connect, all four arguments are defined and the appropriate values are there.
I do not know what else can be wrong.
value (= "E5"). Value (server) = sheets ("index"). Range ("E6"). Value app = sheets ("index") value ("E7"). Value DB = Sheets ("Index"). Range ("E8"). Value UserId = Sheets ("Index"). Range ("E10"). Value psw = InputBox ( "Password") DSN = "source" X = HypDisconnectAll () if HypConnectionExists (DSN) if x = HypRemoveConnection (DSN) X = HypCreateConnection (_ blank, _ UserId, _ psw, _ "Essbase", _ URL _ server _ application, _ Db, _ DSN, _ connection for warning "retrievals") turn X = HypSetConnAliasTable ( "source", "Code_and_Desc") X = HypSetGlobalOption (5, 3) stop 'X = H ypSetGlobalOption (6, true) 'use thousands separator X = HypSetGlobalOption (15, maintaining it really is) worksheet Sheet.Activate RR = range ( "A1") format for each sheet. Price is RR = "" then RR = "A1" if RR & lt; & Gt; "Do not retrieve" Then x = HypConnect (Sheet.Name, User-ID, psw, DSN) X = HypSetSheetOption (Sheet.Name, 5, 0) x = HypSetSheetOption (Sheet.Name, 6, false) X = HypSetSheetOption (sheet. name, 7, false) X = HypSetSheetOption (Sheet.Name, 8, false) X = HypSetSheetOption (Sheet.Name, 13, "#numericzero") X = HypSetSheetOption (Sheet.Name, 16, 2) x = HypRetrieveRange (Sheet .Name, RR, DSN) Ends the next sheet X = HypSetGlobalOption (5, 2) 'Warning again x = HypRemoveConnection (DSN) x = HypDisconnectAll () MsgBox ("Full") End Sub < / Code>
Checked out, I got the name of the server wrong and did not get it. Today, with Fresher's eyes, I got the problem and the code above works fine even though the problem was actually in the HypCreateConnection line, that function call returned 0 error code then there was an error due to using HypConnect with invalid connection - And returned an inappropriate error code.
No comments:
Post a Comment