Hello can someone please tell me what could be the problem in my calendar. So let me explain whats happening. So first im trying to make a scheduler application and im using a WPF scheduler in VB, so to begin with, the tab of a calendar needs to display 3 items (Subject, Professor Name, Courses) so what i need to do is to choose a room first and then drag a subject name from the listbox (like this Sample1) and then next i need to drag a professors name (Sample2) and then heres where the problems starts
So it already displays two items (Subject and Professor) now i need to drag an item from Course listbox, but the problem is whenever I put a course to the tab of a calendar, it becomes like this instead
So the goal here is to show 3 dragged items but instead, it only shows 2 and the course is overwriting the name of the subject. Please help me, thank you! If you want to see the whole codes, heres the link https://drive.google.com/file/d/1fWKisPr9qDh54B4EMdwWJbY3KFgi_xfc/view?usp=sharing
Heres the code of where you can drag the items
'Dragging Data to Calendar
Sub Add_list_item(ByVal list As String)
Delay.Delay(1)
Dim count = 0
For Each item As CalendarItem In Calendar1.GetSelectedItems()
count += 1
If count > 1 Then
Return
Else
Dim get_item_end_time As DateTime = item.EndDate.AddHours(2)
get_item_end_time = get_item_end_time.AddMinutes(30)
Dim item_start_time = item.StartDate
Dim item_end_time = get_item_end_time
Dim item_tooltip = item.StartDate.ToString()
Dim start_time = item.StartDate.ToString("HH:mm tt")
Dim end_time = item.EndDate.ToString("HH:mm tt")
Dim dat_start As Date = item_tooltip
Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture("en-US")
Dim dtfi As DateTimeFormatInfo = ci.DateTimeFormat
dtfi.AbbreviatedDayNames = {"Sun", "1", "2", "3", "4",
"5", "6"}
Dim output_start As String = String.Format(ci, "{0:ddd}", dat_start.AddDays(0))
Dim item_text = CStr(item.Text)
Dim parts As String() = item_text.Split(New String() {Environment.NewLine},
StringSplitOptions.None)
Dim get_item_total_hours = (item.EndDate - item.StartDate).TotalHours
Dim get_start_time As DateTime
Dim get_end_time As DateTime
If get_item_total_hours = 1 Then
get_start_time = item.StartDate.AddMinutes(-30)
get_end_time = item.EndDate.AddMinutes(30)
ElseIf get_item_total_hours = 1.5 Then
get_start_time = item.StartDate.AddHours(-1)
get_end_time = item.EndDate.AddHours(1)
ElseIf get_item_total_hours = 2 Then
get_start_time = item.StartDate.AddHours(-1).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(1).AddMinutes(30)
ElseIf get_item_total_hours = 2.5 Then
get_start_time = item.StartDate.AddHours(-2)
get_end_time = item.EndDate.AddHours(2)
ElseIf get_item_total_hours = 3 Then
get_start_time = item.StartDate.AddHours(-2).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(2).AddMinutes(30)
ElseIf get_item_total_hours = 3.5 Then
get_start_time = item.StartDate.AddHours(-3)
get_end_time = item.EndDate.AddHours(3)
ElseIf get_item_total_hours = 4 Then
get_start_time = item.StartDate.AddHours(-3).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(3).AddMinutes(30)
ElseIf get_item_total_hours = 4.5 Then
get_start_time = item.StartDate.AddHours(-4)
get_end_time = item.EndDate.AddHours(4)
ElseIf get_item_total_hours = 5 Then
get_start_time = item.StartDate.AddHours(-4).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(4).AddMinutes(30)
ElseIf get_item_total_hours = 5.5 Then
get_start_time = item.StartDate.AddHours(-5)
get_end_time = item.EndDate.AddHours(5)
ElseIf get_item_total_hours = 6 Then
get_start_time = item.StartDate.AddHours(-5).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(5).AddMinutes(30)
End If
If (ListBox1_Instructor.Items.Contains(list) = True) Then
Call Check_if_instructor(list)
End If
If parts.Count >= 3 Then
If (instructor_name = True) Then
Call Get_instructor_code(instructor_gender + list)
Call Get_course_name(corSec_id)
Call checkInstructorSchedule(start_time, end_time, output_start, instructor_id)
If (instructor_name = True) Then
If instructor_gender = "Male" Then
instructor_gender = "Mr. "
Else
instructor_gender = "Ms. "
End If
If item.Text <> "" Then
item.Text = parts(0) + vbNewLine + vbNewLine + instructor_gender + list
item.ApplyColor(Color.RoyalBlue)
End If
instructor_name = False
End If
Else
item.ApplyColor(Color.RoyalBlue)
item.Text = list + vbNewLine + vbNewLine + parts(2) + vbNewLine + vbNewLine
End If
ElseIf parts.Count = 1 Then
If (instructor_name = True) Then
Call Get_instructor_code(instructor_gender + list)
Call Get_course_name(corSec_id)
Call checkInstructorSchedule(start_time, end_time, output_start, instructor_id)
If (instructor_name = True) Then
If instructor_gender = "Male" Then
instructor_gender = "Mr. "
Else
instructor_gender = "Ms. "
End If
If item.Text <> "" Then
item.Text = parts(0) + vbNewLine + vbNewLine + instructor_gender + list
item.ApplyColor(Color.RoyalBlue)
End If
instructor_name = False
End If
Else
item.ApplyColor(Color.RoyalBlue)
item.Text = list + vbNewLine + vbNewLine + parts(parts.Count - 1) + vbNewLine + vbNewLine
End If
End If
Calendar1.Invalidate(item)
End If
Next
End Sub
I'm trying to create a macro to cycle between three players on a game that I am making on PowerPoint. However, when I run the code, it changes once and and gets stuck. It won't cycle through the array. In the code I plan to change the color of the shape containing the player's name as well as show transparent gray buttons over the other players' boxes so that they can't adjust their scores. Here is my code. Thanks in advance.
Sub SwitchPlayers()
Dim oSl As Slide
Dim RGB As String
Dim i As Long
Dim myTurn() As Integer
ReDim myTurn(2) '0, 1, 2... 3 compartments
Set oSl = ActivePresentation.Slides(5)
For i = 0 To 2
myTurn(i) = i + 1
If myTurn(i) = 0 Then
oSl.Shapes("T1NB").Fill.ForeColor.RGB = vbYellow
oSl.Shapes.Range(Array("T2NB", "T3NB")).Fill.ForeColor.RGB = vbWhite
oSl.Shapes.Range(Array("T2+1G", "T2-1G", "T3+1G", "T3-1G")).Visible = True
oSl.Shapes.Range(Array("T1+1G", "T1-1G")).Visible = False
ElseIf myTurn(i) = 1 Then
oSl.Shapes("T2NB").Fill.ForeColor.RGB = vbYellow
oSl.Shapes.Range(Array("T1NB", "T3NB")).Fill.ForeColor.RGB = vbWhite
oSl.Shapes.Range(Array("T1+1G", "T1-1G", "T3+1G", "T3-1G")).Visible = True
oSl.Shapes.Range(Array("T2+1G", "T2-1G")).Visible = False
ElseIf myTurn(i) = 2 Then
oSl.Shapes("T3NB").Fill.ForeColor.RGB = vbYellow
oSl.Shapes.Range(Array("T1NB", "T2NB")).Fill.ForeColor.RGB = vbWhite
oSl.Shapes.Range(Array("T1+1G", "T1-1G", "T2+1G", "T2-1G")).Visible = True
oSl.Shapes.Range(Array("T3+1G", "T3-1G")).Visible = False
End If
Next i
End Sub
Thanks again to #SteveRindsberg. I figured it out and added Select Case to my toolbox. This is the code that I came up with. Works great.
Sub SwitchPlayers2()
Dim oSl As Slide
Dim RGB As String
Set oSl = ActivePresentation.Slides(5)
Select Case iLastRan
Case Is = 0
oSl.Shapes("T1NB").Fill.ForeColor.RGB = vbYellow
oSl.Shapes.Range(Array("T2NB", "T3NB")).Fill.ForeColor.RGB = vbWhite
oSl.Shapes.Range(Array("T2+1G", "T2-1G", "T3+1G", "T3-1G")).Visible = True
oSl.Shapes.Range(Array("T1+1G", "T1-1G")).Visible = False
iLastRan = iLastRan + 1
Case Is = 1
oSl.Shapes("T2NB").Fill.ForeColor.RGB = vbYellow
oSl.Shapes.Range(Array("T1NB", "T3NB")).Fill.ForeColor.RGB = vbWhite
oSl.Shapes.Range(Array("T1+1G", "T1-1G", "T3+1G", "T3-1G")).Visible = True
oSl.Shapes.Range(Array("T2+1G", "T2-1G")).Visible = False
iLastRan = iLastRan + 1
Case Is = 2
oSl.Shapes("T3NB").Fill.ForeColor.RGB = vbYellow
oSl.Shapes.Range(Array("T1NB", "T2NB")).Fill.ForeColor.RGB = vbWhite
oSl.Shapes.Range(Array("T1+1G", "T1-1G", "T2+1G", "T2-1G")).Visible = True
oSl.Shapes.Range(Array("T3+1G", "T3-1G")).Visible = False
iLastRan = iLastRan + 1
If iLastRan > 2 Then
iLastRan = 0
End If
End Select
End Sub
I'm trying to add a couple of simple macros to a file that is a shared excel binary workbook. The problem whenever the file is unshared the macro does not work anymore. The code is as following:
Sub uploadMain()
Dim xlsFile As String
Dim wbResults As Workbook
Dim wbmCall As Workbook
Dim agmtCdCell As Range
Dim amtCldCell As Range
Dim srchRange As Integer
Dim callClmn As Integer
Dim srchString As String
Dim callAmt As String
Dim notFound As String
Dim lastRowNo As Long
Dim srchRowNo As Long
Dim srcRowNo As Long
Dim customView As Boolean
Dim amntReplaced As Boolean
Dim asset_column As Integer
Dim typ
Dim quantity_column As Integer
Dim quantity As Variant
Dim unique_identifier As Integer
Dim lastrow_updated As Integer
Dim lastrow_preupload As Integer
Dim wiersz
Dim asset As String
Dim state As String
Dim old_row As Integer
Dim amp As String
Dim loaded
Dim direction_column As Integer
Dim delivery_type As String
Sheets("Calls").Select
ThisWorkbook.Save
customView = False
amntReplaced = False
Application.ScreenUpdating = False
Set wbmCall = ThisWorkbook
asset_column = Cells.Find(What:="Asset", After:=[A1], LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Column
quantity_column = Cells.Find(What:="Quantity", After:=[A1], LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Column
srchRange = Cells.Find(What:="Agmt Code", After:=[A1], LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Column
direction_column = Cells.Find(What:="Direction", After:=[A1], LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Column
xlsFile = Application.GetOpenFilename("Excel Workbooks (*.xls; *.xlsx),*.xls;*.xslx", , "Select Acadia extract to import.", , False)
If xlsFile = "False" Then Exit Sub
Set wbResults = Workbooks.Open(Filename:=xlsFile, UpdateLinks:=0)
' call amtcalled removed
Dim relocList() As Variant
Dim lngPosition As Integer
Dim startingRow As Range
Dim i As Long
Dim temporary_row As Integer
wbmCall.Activate
Dim b As Integer
Sheets("AcadiaFeeds").Select
Dim amp_array()
If Range("J65536").End(xlUp).Row > 2 Then
Cells(Range("J65536").End(xlUp).Row, 10).Select 'last row
lastrow_preupload = Range("J65536").End(xlUp).Row
amp_array = Range(Selection, Selection.End(xlUp))
End If
wbResults.Activate
'________________
For i = 2 To lastrow_preupload
If Range("Z" & i).Value = "Deliver" Then
ActiveSheet.Range("E" & i).Select
Selection.Replace What:="GROSS", Replacement:="OTM", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Else
ActiveSheet.Range("E" & i).Select
Selection.Replace What:="GROSS", Replacement:="ITM", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
End If
Next i
'_______________________
relocList = Array("Margin Call Amp ID", "Delivery Type", "Amp ID", "Call Type", "Business State", "Valuation Date", "Total Call Amount", "Our Unique Agreement Identifier", "Quantity", "FX Currency", "Security Id", "Type")
Stop
For lngPosition = LBound(relocList) To UBound(relocList)
Set startingRow = ActiveSheet.Rows(1).Find(What:=relocList(lngPosition), After:=[A1], LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
If Not startingRow Is Nothing Then
Columns(startingRow.Column).Select
Selection.Cut
Columns(1).Select
Selection.Insert Shift:=xlToRight
End If
Next lngPosition
Columns(13).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Delete
Dim nextone As String
j = 1
i = 2
Do Until i = Range("A65000").End(xlUp).offset(1, 0).Row
If Cells(i, 8).Value = "Partial Disputed" Then
Rows(i).Delete
Else
i = i + 1
End If
If Cells(i, 11).Value = "Deliver" Then Cells(i, 11).Value = "Pledge"
If Cells(i, 1).Value = "PLEDGE" Then
temporary_row = WorksheetFunction.Match(Cells(i, 12), Range("J:J"), 0)
Cells(i, 5) = Cells(temporary_row, 5)
Cells(i, 8) = Cells(temporary_row, 8)
End If
Loop
Dim As String
i = 1
'remove blanks
=======================================================================================================================================================
lastRowNo = Range("A65000").End(xlUp).Row
wbmCall.Activate
Sheets("AcadiaFeeds").Select
If ActiveSheet.FilterMode = True Then ActiveSheet.FilterMode = False 'gdyby komus wpadl do lepetyny glupi pomysl dodawania filtra w Acadia Feeds
srchRowNo = Range("A65000").End(xlUp).Row + 5
If srchRowNo < 10 Then
srchRowNo = 10
lastrow_preupload = 10
End If
Range("L" & srchRowNo).Value = "Uploaded " & Format(Now, "mmm dd, yyyy hh:mm:ss") & " by " & LCase(Environ("USERNAME"))
srcRowNo = 1
i = 1
Do Until i > lastRowNo
Range("A" & srchRowNo & ":K" & srchRowNo).Value = wbResults.Sheets(1).Range("A" & srcRowNo & ":K" & srcRowNo).Value
srchRowNo = srchRowNo + 1
srcRowNo = srcRowNo + 1
i = i + 1
Loop
wbResults.Close SaveChanges:=False
Set wbResults = Nothing
wbmCall.Activate
Set wbmCall = Nothing
ActiveWorkbook.Sheets("Calls").Select
If ActiveSheet.AutoFilterMode = True Then
customView = True
Application.EnableEvents = False
ActiveWorkbook.CustomViews.Add ViewName:="doAcadii", RowColSettings:=True
ActiveSheet.AutoFilterMode = False
Application.EnableEvents = True
End If
ActiveWorkbook.Sheets("AcadiaFeeds").Select
callClmn = 5 'Our Unique Agreement Identifier na sztywno
cTypeClmn = 9 'call type na sztywno w kolumnie 5tej
=======================================================================================================================================================
backAtLoop:
srchRowNo = lastrow_preupload
lastrow_updated = Range("A65000").End(xlUp).Row
Do Until srchRowNo = lastrow_updated + 1
ActiveWorkbook.Sheets("AcadiaFeeds").Select
srchRowNo = srchRowNo + 1
amp = Cells(srchRowNo, callClmn + 5).Value ' amp ID
srchString = Cells(srchRowNo, callClmn).Value 'od dolu bierze unique identifier
callAmt = Cells(srchRowNo, callClmn + 1).Value 'amt called
cType = Cells(srchRowNo, cTypeClmn).Value 'call type
quantity = Cells(srchRowNo, callClmn - 1).Value 'ilosc papierow
state = Cells(srchRowNo, callClmn + 3).Value 'business state pledge accepted
delivery_type = Cells(srchRowNo, callClmn + 6)
typ = Cells(srchRowNo, 1).Value 'margin_call lub pledge
If Cells(srchRowNo, callClmn - 3).Value <> "CASH" Then
asset = Cells(srchRowNo, callClmn - 3).Value ' aktywo
Else:
asset = Cells(srchRowNo, callClmn - 2).Value
End If
Sheets("Calls").Select
Set foundmatchx = Columns(srchRange).Find(What:=srchString, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If typ = "MARGIN_CALL" Then
If Application.WorksheetFunction.CountIf(Columns(srchRange), srchString) = 0 Then 'sprawdza dany agreement jest w mcalls table
Sheets("AcadiaFeeds").Select
notFound = notFound & "; " & srchString
Range("A" & srchRowNo & ":I" & srchRowNo).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("K" & srchRowNo).Value = "Not Found"
ElseIf Application.WorksheetFunction.CountIf(Columns(srchRange), srchString) <> 0 Then
'howMany = Application.WorksheetFunction.CountIf(Columns(srchRange), srchString)
foundmatchx.offset(0, 3).Activate ' aktywuje offset AMT called
If ActiveCell.offset(0, 11) = "Initial" And cType = "Initial" Then 'idk nor care
'nowt to do here
ElseIf cType = "Initial" And Right(srchString, 4) <> "FBCO" Then
ActiveWorkbook.Sheets("AcadiaFeeds").Select 'acadia feeds
Range("A" & srchRowNo & ":E" & srchRowNo).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("F" & srchRowNo).Value = "IM call not found"
GoTo nexxtSrchRowNo
ElseIf cType = "Initial" And Right(srchString, 4) = "FBCO" Then
'nowt to do here
Else
Columns(srchRange).FindNext(foundmatchx).offset(0, 3).Activate
End If
Range("J" & srchRowNo).Value = "Already Loaded", Range("A" & srchRowNo & ":I" & srchRowNo).Select
If ActiveCell.Value = callAmt Then
ActiveWorkbook.Sheets("AcadiaFeeds").Select 'acadia feeds
With ActiveWorkbook.Sheets("AcadiaFeeds").Range("A" & srchRowNo & ":I" & srchRowNo).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("K" & srchRowNo).Value = "Already Loaded"
ElseIf ActiveCell.Value <> "" And ActiveCell.Value <> callAmt Then
ActiveWorkbook.Sheets("AcadiaFeeds").Select 'acadia feeds
Range("A" & srchRowNo & ":E" & srchRowNo).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("K" & srchRowNo).Value = "Loaded w/ different amt - please investigate"
amntReplaced = True
Else
ActiveCell.Value = callAmt
ActiveCell.offset(0, 20).Value = "loaded from AcadiaFeeds sheet row# " & srchRowNo
End If
Else
MsgBox "Something unexpected happend"
End If
nexxtSrchRowNo:
End If
ActiveWorkbook.Sheets("AcadiaFeeds").Select
If typ = "PLEDGE" Then
Sheets("Calls").Select 'calls
wiersz = foundmatchx.Row
If IsVarArrayEmpty(amp_array) = False Then
j = 1
loaded = "not_loaded"
For j = 1 To UBound(amp_array)
If amp_array(j, 1) = amp Then
loaded = "already_loaded"
j = UBound(amp_array)
End If
Next
Else: loaded = "not_loaded"
End If
Select Case loaded
Case "already_loaded"
If state = "Pledge Accepted" Then
If IsEmpty(Cells(wiersz, quantity_column)) = False And quantity <> Cells(wiersz, quantity_column) Then
Application.Union(Range(Cells(wiersz + 1, srchRange - 2), Cells(wiersz + 1, srchRange - 1)), Range(Cells(wiersz + 1, srchRange + 1), Cells(wiersz + 1, srchRange + 2))).Style = "Good"
Else:
Application.Union(Range(Cells(wiersz, srchRange - 2), Cells(wiersz, srchRange - 1)), Range(Cells(wiersz, srchRange + 1), Cells(wiersz, srchRange + 2))).Style = "Good"
End If
End If
Case "not_loaded"
If delivery_type = Cells(wiersz, direction_column) And IsEmpty(Cells(wiersz, quantity_column)) = True Then
If state = "Pledge Accepted" Then
Application.Union(Range(Cells(wiersz, srchRange - 2), Cells(wiersz, srchRange - 1)), Range(Cells(wiersz, srchRange + 1), Cells(wiersz, srchRange + 2))).Style = "Good"
End If
Cells(wiersz, quantity_column) = quantity
Cells(wiersz, asset_column) = asset
ElseIf delivery_type = Cells(wiersz, direction_column) And IsEmpty(Cells(wiersz, quantity_column)) = False Then
Cells(wiersz, quantity_column).Select
Call MainModule.insertRow
Cells(wiersz + 1, quantity_column) = quantity
Cells(wiersz + 1, asset_column) = asset
If state = "Pledge Accepted" Then
Application.Union(Range(Cells(wiersz + 1, srchRange - 2), Cells(wiersz + 1, srchRange - 1)), Range(Cells(wiersz + 1, srchRange + 1), Cells(wiersz + 1, srchRange + 2))).Style = "Good"
End If
ElseIf delivery_type <> Cells(wiersz, direction_column) Then
howMany = Application.WorksheetFunction.CountIf(Columns(srchRange), srchString)
i = 1
For i = 1 To howMany
Set foundmatchx = Columns(srchRange).FindNext(foundmatchx)
'daje find dla danego agreeementu
temporary_row = foundmatchx.Row
If delivery_type = Cells(temporary_row, direction_column) And IsEmpty(Cells(temporary_row, quantity_column)) = True Then
'1_17 change
If state = "Pledge Accepted" Then
Application.Union(Range(Cells(temporary_row, srchRange - 2), Cells(temporary_row, srchRange - 1)), Range(Cells(temporary_row, srchRange + 1), Cells(temporary_row, srchRange + 2))).Style = "Good"
End If
Cells(temporary_row, quantity_column) = quantity
Cells(temporary_row, asset_column) = asset
i = howMany
End If
Next
End If
End Select
End If
Loop
ActiveWorkbook.Sheets("Calls").Select
'aplikuje filtr spowrotem
If customView = True Then
Application.EnableEvents = False
With ActiveWorkbook.CustomViews("doAcadii")
.Show
.Delete
End With
Application.EnableEvents = True
End If
Application.ScreenUpdating = True
'ponizsze IF dodane 07/30
If amntReplaced = True Then
MsgBox "Acadia extract uploaded, but some calls were loaded with different call amounts." & vbCrLf & _
"Please investigate for issues before saving this spreadsheet."
Else
MsgBox "Acadia extract uploaded!"
End If
End Sub
Sub amtsCalled()
Application.ScreenUpdating = False
Dim relocList() As Variant
Dim lngPosition As Integer
Dim startingRow As Range
Dim i As Long
Dim temporary_row As Integer
wbmCall.Activate
Sheets("AcadiaFeeds").Select
Dim amp_array()
Cells(Range("J65536").End(xlUp).Row, 10).Select 'last row
MsgBox (Cells(Range("J65536").End(xlUp).Row, 10))
amp_array = Range(Selection, Selection.End(xlUp))
wbResults.Activate
relocList = Array("Margin Call Amp ID", "Amp ID", "Call Type", "Business State", "Valuation Date", "Total Call Amount", "Our Unique Agreement Identifier", "Quantity", "FX Currency", "Security Id", "Type")
Stop
For lngPosition = LBound(relocList) To UBound(relocList)
Set startingRow = ActiveSheet.Rows(1).Find(What:=relocList(lngPosition), After:=[A1], LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
If Not startingRow Is Nothing Then
Columns(startingRow.Column).Select
Selection.Cut
Columns(1).Select
Selection.Insert Shift:=xlToRight
End If
Next lngPosition
Columns(12).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Delete
Dim nextone As String
i = 2
Do Until i = Range("A65000").End(xlUp).offset(1, 0).Row
For j = 1 To UBound(amp_array)
If Cells(i, 10).Value = amp_array(j, 1) Then GoTo nextone
Next
If Cells(i, 8).Value = "Partial Disputed" Then
Rows(i).Delete
Else
i = i + 1
End If
If Cells(i, 1).Value = "PLEDGE" Then
temporary_row = WorksheetFunction.Match(Cells(i, 11), Range("J:J"), 0)
Cells(i, 5) = Cells(temporary_row, 5)
End If
nextone:
Loop
'remove blanks
On Error GoTo 0
Exit Sub
Application.ScreenUpdating = True
End Sub
Sub ss()
Application.ScreenUpdating = True
End Sub
Function IsVarArrayEmpty(anArray As Variant)
Dim i As Integer
On Error Resume Next
i = UBound(anArray, 1)
If Err.Number = 0 Then
IsVarArrayEmpty = False
Else
IsVarArrayEmpty = True
End If
End Function
Some of the lines are in Polish, is this causing the issue with uploading new macros and working when it's unshared?
It looks like this is by design:
"Once you share a workbook, any Visual Basic project it contains is no longer accessible. Excel can’t deal with multiple users editing the same macros, so it simply prevents changes to those macros. You can’t record new macros, either. However, you can run macros from shared workbooks."
Ref: https://www.oreilly.com/library/view/programming-excel-with/0596007663/ch08s03.html
I have website which is working on my one server now I have migrated to another server changed the connection string. But one weird thing is some pages working fine but some page show me " page can not be displayed error message. I am new in VBscript Can anyone help me what am missing"
Below is the code of page which is not working on new server but working on old server
Microsoft VBScript runtime error '800a01a8' : object required
<%#LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% if session("MM_Username") = "" or isnull(session("MM_Username")) then
response.redirect("/login.asp")
end if
%>
<%
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then
MM_editConnection = MM_v3_STRING
MM_editTable = "dbo.custMessage"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "Change.asp"
MM_fieldsStr = "textarea|value"
MM_columnsStr = "message|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim change__MMColParam
change__MMColParam = "1"
If (Request("MM_EmptyValue") <> "") Then
change__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim change
Dim change_numRows
Set change = Server.CreateObject("ADODB.Recordset")
change.ActiveConnection = MM_v3_STRING
change.Source = "SELECT * FROM dbo.custMessage WHERE id = " + Replace(change__MMColParam, "'", "''") + ""
change.CursorType = 0
change.CursorLocation = 2
change.LockType = 1
change.Open()
change_numRows = 0
%>
<%
'setup database connection
dim conn
set conn = server.CreateObject ("ADODB.Connection")
conn.ConnectionString = "Provider=SQLOLEDB;User ID=***;Password=***;Initial Catalog=heart_Test;Data Source=****;"
conn.Open
%>
So here is the answer.
Start Internet Services Manager.
Click Default Web Site, and then click Properties.
Double-click ASP in the Features pane.
Expand Behavior.
Click Enable Parent Paths.
Click True for Enable Parent Paths.
Click Apply.
I've been looking into this, and for the life of me, I can't figure out where I am missing something. I am missing either a 'Next' or a 'Do', but it looks like I have it all in there.
Any help is appreciated.
Do
ufCCB.Show
If Continue = True Then
iret = iim1.iimInit
iret = iim1.iimSet("UNAME", UN)
iret = iim1.iimSet("PWORD", PW)
iret = iim1.iimPlay("VH-ccb-logIn-User")
If iret = 1 Then
retry = False
Else
TryCount = TryCount + 1
iret = iim1.iimExit
End If
If TryCount = 2 Then
retry = False
MsgBox "Alas my friend, you have inputted the wrong password twice. Please try again."
Continue = False
End If
Else
retry = False
End If
Loop Until retry = False
' Set iim1 = CreateObject("imacros")
' iret = iim1.iimInit
' iret = iim1.iimSet("UNAME", UN)
' iret = iim1.iimSet("PWORD", PW)
' iret = iim1.iimPlay("VH-ccb-logIn-User")
TotalFailures = 0
iret = iim1.iimPlay("VH-CCB-Reset")
'Application.Wait (Now() + "00:00:01")
'Step AD: Insert Last Start Time/Date
ThisWorkbook.Sheets("Control").Cells(2, 2) = Now()
ThisWorkbook.ActiveSheet.Select
'Continue is set from the Login to confirm that CC&B is open and ready
If Continue Then
iret = iim1.iimPlay("VH-CCB-reset")
Else: GoTo IThinkWereDoneHere
End If
Do
TryCount = 0
AssignCurrentVars:
'Restart the browser if too many errors occur.
If TotalFailures = 3 Then
iret = iim1.iimExit
End If
For Each ws In Workbooks("ElecOpsCSD_FollowUp_iMacro.xlsm").Worksheets
ws.Select
If ws.Name <> "Control" And ws.Name <> "OutputArchive" And ws.Name <> "CC&B_Process" Then
ws.Activate
If ThisWorkbook.ActiveSheet.Cells(RowCntr, 1).Value <> "" Then
If ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = "" Then
Do
FieldOrderID = ThisWorkbook.ActiveSheet.Cells(RowCntr, 1).Text
If Len(FieldOrderID) < 3 Then
FieldOrderID = ""
TryCount = TryCount + 1
If TryCount = 3 Then
GoTo IThinkWereDoneHere
End If
End If
FO_Status = ThisWorkbook.ActiveSheet.Cells(RowCntr, 2).Text
FO_Comments = ThisWorkbook.ActiveSheet.Cells(RowCntr, 3).Text
Badge_Number = ThisWorkbook.ActiveSheet.Cells(RowCntr, 4).Text
Device_Type = ThisWorkbook.ActiveSheet.Cells(RowCntr, 5).Text
Install_Time = ThisWorkbook.ActiveSheet.Cells(RowCntr, 6).Text
Removal_Time = ThisWorkbook.ActiveSheet.Cells(RowCntr, 7).Text
SA_Status = ThisWorkbook.ActiveSheet.Cells(RowCntr, 8).Text
SA_Start_Date = ThisWorkbook.ActiveSheet.Cells(RowCntr, 9).Text
SA_Start_Meter_Read = ThisWorkbook.ActiveSheet.Cells(RowCntr, 10).Text
Dispatch_Group = ThisWorkbook.ActiveSheet.Cells(RowCntr, 11).Text
Status = ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Text
'User Initiated Stop Point
If QUITTER = True Then
MsgBox ("Process Halted by User")
GoTo IThinkWereDoneHere
End If
'Error Handler
If FieldOrderID = "" Then
TryCount = TryCount + 1
RowCntr = RowCntr + 1
If TryCount = 3 Then
MsgBox ("Encountered records missing Field Order ID. Process Complete.")
GoTo IThinkWereDoneHere
End If
GoTo AssignCurrentVars
End If
'Skip records that have already been processed, even partially.
If Status <> "" Then
RowCntr = RowCntr + 1
GoTo AssignCurrentVars
End If
'Step 01a: Go to "Account Information" tab
iret = iim1.iimPlay("IH-CCB-AcctInfo")
'Step 02a: Click the Premise context menu and select "Go To Field Order"
iret = iim1.iimPlay("IH-ElecOpsCSD-GoTo_Premise_FO")
'Step 03a: Enter FOID, provided by the spreadsheet, into "Field Order ID" field and click related binoculars/search button.
iret = iim1.iimSet("FieldOrderID", FieldOrderID)
iret = iim1.iimPlay("IH-ElecOPSCSD-Input_FOID")
'Step 04a: Extract Field Order Status
iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_FO_Status")
If iret = -1 Then
Status = "Stated Field Order ID doesn't exist in CC&B."
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
iret = iim1.iimSet("UNAME", UN)
iret = iim1.iimSet("PWORD", PW)
iret = iim1.iimPlay("VH-ccb-logIn-User")
Else:
FO_Status = iim1.iimGetLastExtract(1)
ThisWorkbook.ActiveSheet.Cells(RowCntr, 2).Value = FO_Status
Status = "FO_Status has been extracted"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
End If
'Step 04b: Extract Comments
iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_FO_Comments")
FO_Comments = iim1.iimGetLastExtract(1)
ThisWorkbook.ActiveSheet.Cells(RowCntr, 3).Value = FO_Comments
Status = "FO_Comments have been extracted"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
'Step 04c: Extract Dispatch Group
iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_Dispatch_Grp")
Dispatch_Group = iim1.iimGetLastExtract(1)
ThisWorkbook.ActiveSheet.Cells(RowCntr, 11).Value = Dispatch_Group
Status = "Dispatch_Group has been extracted"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
'Step 05a: Go to 'Activities' tab
iret = iim1.iimPlay("IH-CCB-GoTo_FOMain_FOActivities")
'Step 06a: Go to 'Service Point ID' context menu, and select "Go To Service Point"
iret = iim1.iimPlay("IH-ElecOpsCSD-GoTo_SPIDContext_SP")
'Step 07a: Go to 'Device History' tab
iret = iim1.iimPlay("IH-ElecOpsCSD-GoTo_DeviceHistory")
'Step 08a: Extract Badge Number
iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_Badge")
Badge_Number = iim1.iimGetLastExtract(1)
ThisWorkbook.ActiveSheet.Cells(RowCntr, 4).Value = Badge_Number
Status = "Badge_Number has been extracted"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
'Step 08b: Extract Device Type
iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_Device_Type")
Device_Type = iim1.iimGetLastExtract(1)
ThisWorkbook.ActiveSheet.Cells(RowCntr, 5).Value = Device_Type
Status = "Device_Type has been extracted"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
If Badge_Number = "#EANF#" Or Device_Type = "#EANF#" Then
Status = "No device history exists"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
GoTo Step09a
Else:
GoTo Step08c
End If
'Step 08c: Extract Install Date/Time
Step08c:
iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_InstallTime")
Install_Time_PreTrim = iim1.iimGetLastExtract(1)
Install_Time = Left(Install_Time_PreTrim, 10)
'Install_Time = Replace(Install_Time, "-", "/")
ThisWorkbook.ActiveSheet.Cells(RowCntr, 6).Value = Install_Time
Status = "Meter Install_Date/Time has been extracted"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
'Step 08d: Extract Removal Date/Time
'iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_RemovalTime")
'Removal_Time = iim1.iimGetLastExtract(1)
'ThisWorkbook.Sheets("Input&Output").Cells(RowCntr, 7).Value = Removal_Time
'Status = "Meter Removal_Date/Time has been extracted"
'ThisWorkbook.Sheets("Input&Output").Cells(RowCntr, 12).Value = Status
'Step 09a: Go to 'SP/SA' tab.
Step09a:
iret = iim1.iimPlay("IH-ElecOpsCSD-GoTo_SPSA")
'Step 09c: Go To 'Start Meter Read' context menu
If Badge_Number = "#EANF#" Or Device_Type = "#EANF#" Then
GoTo Step09b2
Else:
GoTo Step09c
Step09c:
iret = iim1.iimPlay("IH-ElecOpsCSD-GoTo_StartMeterRead")
End If
'Step 09d: Extract Register Reading.
iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_MeterRead")
SA_Start_Meter_Read = iim1.iimGetLastExtract(1)
ThisWorkbook.ActiveSheet.Cells(RowCntr, 10).Value = SA_Start_Meter_Read
Status = "SA_Start_Meter_Read has been extracted"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
If Badge_Number = "#EANF#" Or Device_Type = "#EANF#" Or Removal_Time = "#EANF#" Or SA_Start_Meter_Read = "#EANF#" Then
Status = "No device history exists"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
'iret = iim1.iimPlay("VH-CCB-reset")
'RowCntr = RowCntr + 1
'GoTo AssignCurrentVars
End If
GoTo Step09b
'Step 09b: Go to 'Service Agreement' context menu and select "Go To Service Agreement"
'iret = iim1.iimPlay("IH-ElecOpsCSD-GoTo_SPSA_SA_SA")
Step09b2:
iret = iim1.iimPlay("IH-ElecOpsCSD-GoTo_SA")
GoTo Step10
Step09b:
iret = iim1.iimPlay("IH-ElecOpsCSD-GoTo_Back_SA")
'Step 10a: Extract SA Status
Step10:
iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_SAStatus")
SA_Status = iim1.iimGetLastExtract(1)
ThisWorkbook.ActiveSheet.Cells(RowCntr, 8).Value = SA_Status
Status = "SA_Status has been extracted"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
'Step 10b: Extract SA Date
iret = iim1.iimPlay("IH-ElecOpsCSD-Extract_SADate")
SA_Start_Date = iim1.iimGetLastExtract(1)
ThisWorkbook.ActiveSheet.Cells(RowCntr, 9).Value = SA_Start_Date
Status = "SA Start_Date has been extracted"
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
If Install_Time <> "" And SA_Start_Date <> Install_Time Then
Status = "SA Start Date and Meter Install Dates do not match."
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
GoTo Step11
Else:
Status = "Completed. Necessary information extracted."
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
End If
GoTo Step11
'Step 11: Replace #EANF# with null values for better readability
Step11:
If Badge_Number = "#EANF#" Then
Badge_Number = Replace(Badge_Number, "#EANF#", "")
ThisWorkbook.ActiveSheet.Cells(RowCntr, 4).Value = Badge_Number
Else:
End If
If Device_Type = "#EANF#" Then
Device_Type = Replace(Device_Type, "#EANF#", "")
ThisWorkbook.ActiveSheet.Cells(RowCntr, 5).Value = Device_Type
Status = "No Meter set."
ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value = Status
Else:
End If
If SA_Start_Date = "#EANF#" Then
SA_Start_Date = Replace(SA_Start_Date, "#EANF#", "")
ThisWorkbook.ActiveSheet.Cells(RowCntr, 9).Value = SA_Start_Date
Else:
End If
If SA_Status = "#EANF#" Then
SA_Status = Replace(SA_Status, "#EANF#", "")
ThisWorkbook.ActiveSheet.Cells(RowCntr, 8).Value = SA_Status
Else:
End If
If SA_Start_Meter_Read = "#EANF#" Then
SA_Start_Meter_Read = Replace(SA_Start_Meter_Read, "#EANF#", "")
ThisWorkbook.ActiveSheet.Cells(RowCntr, 10).Value = SA_Start_Meter_Read
Else:
End If
'Step 12a: Reset CC&B.
iret = iim1.iimPlay("VH-CCB-reset")
Loop Until QUITTER = True Or RowCntr = 10000
ElseIf ThisWorkbook.ActiveSheet.Cells(RowCntr, 1).Value <> "" Then
RowCntr = 2
GoTo AssignCurrentVars
ElseIf ThisWorkbook.ActiveSheet.Cells(RowCntr, 12).Value <> "" Then
End If
End If
Workbooks("ElecOpsCSD_FollowUp_iMacro.xlsm").Activate
'RowCntr = 2
Next ws '**THIS IS WHERE I AM GETTING THE COMPILE ERROR**
Loop Until ws.Name = "CC&B_Process"
IThinkWereDoneHere:
ThisWorkbook.Sheets("Control").Cells(4, 2) = Now()
ThisWorkbook.Save
iret = iim1.iimExit()
End Sub
I couldn't find a missing loop or next iterator, but your posted code is missing an If line:
If ws.Name <> "Control" And _
ws.Name <> "OutputArchive" And ws.Name <> "CC&B_Process" Then
doesn't seem to have an ending End If anywhere.
Looks like it should be placed before the Next ws line (my guess):
End If
Next ws
Loop Until ws.Name = "CC&B_Process"
Your liberal use of GoTo is considered bad practice.