Usage of Cookies in User Form in VBA

desaraj4u

New Member
Joined
Sep 15, 2017
Messages
1
Hello Team,
We are trying to use cookies in a UserForm. We have a button in user access form, it should fetch few details in the same window the moment you clicked on the button. Cookies are mandatory to use. can someone help this. Please find the below code we are using
[FONT=&quot]Public Sub StatusAction()[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]On Error GoTo Error_Handler[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] If ActiveWorkbook.Saved Then IsTemplateSaved = True[/FONT]
[FONT=&quot] GlobalSettings.getActionName = getButtonActionStatus[/FONT]
[FONT=&quot] If IsDestinationReachable = False Then[/FONT]
[FONT=&quot] ShowServerNotReachableMsg[/FONT]
[FONT=&quot] Exit Sub[/FONT]
[FONT=&quot] End If[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] If ExcelHandler Is Nothing Then[/FONT]
[FONT=&quot] Set ExcelHandler = New ExcelHandler[/FONT]
[FONT=&quot] End If[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Dim UniqueID As String[/FONT]
[FONT=&quot] UniqueID = SystemFunctions.GenerateUniqueId(gstrSTPAccount)[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Dim FinalStr As String[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] FinalStr = Replace(UniqueID, Chr(13), " ", , , vbTextCompare)[/FONT]
[FONT=&quot] FinalStr = Replace(FinalStr, Chr(10), " ", , , vbTextCompare)[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Dim overridefolder As String[/FONT]
[FONT=&quot] overridefolder = ActiveWorkbook.Worksheets.Item("SWSHEETMETA").Range("B1")[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Dim overridePath As String[/FONT]
[FONT=&quot] overridePath = doSubmit.ResolvePath(overridefolder, GlobalSettings.gstrSTPService, GlobalSettings.gstrSTPAccount)[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Dim selectedLocale As String[/FONT]
[FONT=&quot] selectedLocale = ActiveWorkbook.Worksheets.Item("SWSHEETMETA").Range("F1")[/FONT]
[FONT=&quot] Dim Cookies As String[/FONT]
[FONT=&quot] Cookies = ActiveWorkbook.Worksheets(AmbassadorSheetName).Range("P1")[/FONT]
[FONT=&quot] Dim header As String[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] header = "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" & vbCrLf & _[/FONT]
[FONT=&quot] "authentication:" & gstrSTPAuthentication & vbCrLf & _[/FONT]
[FONT=&quot] "Cookie:" & Cookies & vbCrLf & _[/FONT]
[FONT=&quot] "sppmBaseUrl:" & gstrSTPServerIP & vbCrLf & _[/FONT]
[FONT=&quot] "username:" & gstrSTPAccount & vbCrLf & _[/FONT]
[FONT=&quot] "worksheetPkId:" & gstrSTPWorksheetID & vbCrLf & _[/FONT]
[FONT=&quot] "overrideFolder:" & overridePath & vbCrLf & _[/FONT]
[FONT=&quot] "selectedLocale:" & selectedLocale & vbCrLf & _[/FONT]
[FONT=&quot] "uniqueid:" & FinalStr & vbCrLf & _[/FONT]
[FONT=&quot] "Accept-Encoding:" & "gzip, deflate" & vbCrLf & _[/FONT]
[FONT=&quot] "Accept:" & "*/*" & vbCrLf & _[/FONT]
[FONT=&quot] "Accept-Language:" & "en-us" & vbCrLf & _[/FONT]
[FONT=&quot] "account:" & gstrSTPAccount & vbCrLf & _[/FONT]
[FONT=&quot] "ContentType:" & "application/x-www-form-urlencoded" & vbCrLf & _[/FONT]
[FONT=&quot] "Connection:" & "Keep-Alive" & vbCrLf & _[/FONT]
[FONT=&quot] "Host:" & Replace(gstrSTPService, "-", ":") & vbCrLf & _[/FONT]
[FONT=&quot] "Method:" & "POST" & vbCrLf[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Dim sURL As String[/FONT]
[FONT=&quot] 'sURL = gstrSTPServerIP & "amb/webMyTemplate?" & "selectedLocaleAmb=" & locale[/FONT]
[FONT=&quot] 'sURL = gstrSTPServerIP & gEtMyTemplatesUrl & "?selectedLocaleAmb=" & GlobalSettings.gTempLocale 'locale[/FONT]
[FONT=&quot] Dim TemplateType As String[/FONT]
[FONT=&quot] If ActiveWorkbook.Worksheets(AmbassadorSheetName).Range("B7").Value = "OPPORTUNITY_TEMPLATE" Then[/FONT]
[FONT=&quot] TemplateType = "OPPORTUNITY_TEMPLATE"[/FONT]
[FONT=&quot] Else[/FONT]
[FONT=&quot] TemplateType = "TEMPLATE"[/FONT]
[FONT=&quot] End If[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Dim statusurl As Long[/FONT]
[FONT=&quot] Dim gmtconv As Date[/FONT]
[FONT=&quot] Dim milli As Variant[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] gmtconv = ConvertLocalToGMT(Now)[/FONT]
[FONT=&quot] milli = MillSec("1/1/1970 0:00AM", gmtconv)[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] If InStr(ActiveWorkbook.Worksheets(AmbassadorSheetName).Range("B14").Value, "/snop/") > 0 Then[/FONT]
[FONT=&quot] sURL = gstrSTPServerIP & "snop/index.html?" & "&tmp=" & milli & "&actionname=status&" & GetFolderListStatus(ActiveWorkbook.Worksheets(AmbassadorSheetName).Range("I17"), "xml") & "&worksheetPkId=" & gstrSTPWorksheetID & "&selectedLocaleAmb=" & selectedLocale & "&template_type=" & TemplateType & "&overrideFolder=" & Replace(overridePath, " ", "|") & "#/status" & "?hide=7&"[/FONT]
[FONT=&quot] UserForm1.WebBrowser1.Navigate2 sURL, , , , header[/FONT]
[FONT=&quot] SetFormOpacity UserForm1, 0[/FONT]
[FONT=&quot] UserForm1.Show[/FONT]
[FONT=&quot] Else[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] If InStr(ActiveWorkbook.Worksheets(AmbassadorSheetName).Range("B14").Value, "/planstreaming/") > 0 Then[/FONT]
[FONT=&quot] 'sURL = gstrSTPServerIP & "planstreaming/index.html?actionname=status&" & GetFolderListStatus(ActiveWorkbook.Worksheets(AmbassadorSheetName).Range("I17"), "xml") & "&worksheetPkId=" & gstrSTPWorksheetID & "&selectedLocaleAmb=" & selectedLocale & "&template_type=" & TemplateType & "&overrideFolder=" & Replace(overridePath, " ", "|") & "#/status" & "?hide=7"[/FONT]
[FONT=&quot] 'sURL = gstrSTPServerIP & "planstreaming/index.html?" & "actionname=status" & "&tmp=" & milli & "#/status" & "?hide=7&" & GetFolderListStatus(ActiveWorkbook.Worksheets(AmbassadorSheetName).Range("I17"), "xml") & "&worksheetPkId=" & gstrSTPWorksheetID & "&selectedLocaleAmb=" & selectedLocale & "&template_type=" & TemplateType & "&actionname=status" & "&overrideFolder=" & Replace(overridePath, " ", "|") & "&htmp=" & milli[/FONT]
[FONT=&quot] sURL = gstrSTPServerIP & "planstreaming/index.html?" & "&tmp=" & milli & "&actionname=status&" & GetFolderListStatus(ActiveWorkbook.Worksheets(AmbassadorSheetName).Range("I17"), "xml") & "&worksheetPkId=" & gstrSTPWorksheetID & "&selectedLocaleAmb=" & selectedLocale & "&template_type=" & TemplateType & "&overrideFolder=" & Replace(overridePath, " ", "|") & "#/status" & "?hide=7&"[/FONT]
[FONT=&quot] UserForm1.WebBrowser1.Navigate2 sURL, , , , header[/FONT]
[FONT=&quot] SetFormOpacity UserForm1, 0[/FONT]
[FONT=&quot] UserForm1.Show[/FONT]
[FONT=&quot] Else[/FONT]
[FONT=&quot] sURL = gstrSTPServerIP & "amb/vbastatus" & "?selectedLocaleAmb=" & GlobalSettings.gTempLocale & "&" & "template_type=" & TemplateType[/FONT]
[FONT=&quot] UserForm1.WebBrowser1.Navigate2 sURL, , , , header[/FONT]
[FONT=&quot] SetFormOpacity UserForm1, 0[/FONT]
[FONT=&quot] UserForm1.Show[/FONT]
[FONT=&quot] End If[/FONT]
[FONT=&quot] End If[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] GlobalSettings.getActionName = ""[/FONT]
[FONT=&quot]Exit Sub[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Error_Handler:[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Dim stra As String[/FONT]
[FONT=&quot] stra = "Error in StatusAction function of Actions"[/FONT]
[FONT=&quot] Call ErrorHandler.ErrorHandler(stra)[/FONT]
[FONT=&quot] GlobalSettings.getActionName = ""[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]End Sub[/FONT]
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,214,839
Messages
6,121,891
Members
449,058
Latest member
Guy Boot

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top