VB6: Speech to Text for certain phrases - com

I'm creating a chatbot on Visual Basic 6.
Private Sub GreetingSub()
convo.Text = beconvo & nickname & ": " & Text.Text & vbNewLine & botname &
"Hello! How are you?" & vbNewLine
End Sub
This is a part of my code. So "nickname & ": " & Text.Text" is the user's name and what they wrote in the input box in the actual conversation box. botname & whatever is following that is what the bot replies.
I've tried Set objTextToSpeech = CreateObject("SAPI.spVoice"), however the program freezes and reads the entire conversation box, which is not what i want.
I need the chatbot to only say his reply out loud, not the user's. Any help is appreciated.

Related

Copying and Modyfing the Connection with VBA

I'm currently building a solution using VBA to copy my existing query (API query) and change its parameters depending on the values in columns from the original query.
I'm using the p1 variable that contains a looped column values to be used in API URL
The result should be a multiple sheets with one query each, vba code should loop through a certain column in my first query and then pass this values into each new query.
I encountered a problem. I don't know if its regional formatting issue or not, but i cannot really paste the query into Queries.Add method. I was pretty sure i formatted the "" correctly but:
AS you can see editor flashed this part of code in red (in Notepadd++ with VBA formatting its fine)
Here is my code:
mFormula =
"let" & Chr(13) & "" & Chr(10) & " Source = Json.Document(Web.Contents(""https://rejestr.io/api/v1/krs/"" & p1 & ""/relations"", [Headers=[Authorization=""xxxxxxx""]]))," & Chr(13) & "" & Chr(10) &" #""Converted to Table"" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), " & Chr(13) & "" & Chr(10) & " #""Expanded Column1"" = Table.ExpandRecordColumn(#""Con" & _
"verted to Table"", ""Column1"", {""address"", ""business_insert_date"", ""ceo"", ""current_relations_count"", ""data_fetched_at"", ""first_entry_date"", ""historical_relations_count"", ""id"", ""is_opp"", ""is_removed"", ""krs"", ""last_entry_date"", ""last_entry_no"", ""last_state_entry_date"", ""last_state_entry_no"", ""legal_form"", ""name"", ""name_short"", ""nip"", ""regon"", ""type"", ""w_likwidacji"", ""w_upadlo" & _
"sci"", ""w_zawieszeniu"", ""relations"", ""birthday"", ""first_name"", ""krs_person_id"", ""last_name"", ""organizations_count"", ""second_names"", ""sex""}, {""Column1.address"", ""Column1.business_insert_date"", ""Column1.ceo"", ""Column1.current_relations_count"", ""Column1.data_fetched_at"", ""Column1.first_entry_date"", ""Column1.historical_relations_count"", ""Column1.id"", ""Column1.is_opp"", ""Column1.is_rem" & _
"oved"", ""Column1.krs"", ""Column1.last_entry_date"", ""Column1.last_entry_no"", ""Column1.last_state_entry_date"", ""Column1.last_state_entry_no"", ""Column1.legal_form"", ""Column1.name"", ""Column1.name_short"", ""Column1.nip"", ""Column1.regon"", ""Column1.type"", ""Column1.w_likwidacji"", ""Column1.w_upadlosci"", ""Column1.w_zawieszeniu"", ""Column1.relations"", ""Column1.birthday"", ""Column1.first_name"", ""Column1.krs_person_id"", ""Column1.last_name"", ""Column1.organizations_count"", ""Column1.second_names"", ""Column1.sex""})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Renamed Columns3"""
Also, is it entirely possible to dynamically pass multiple variables from first query to create multiple queries to API service? Maybe someone already did something similar?
Many thanks
Alex
You need a line continuation marker (_) in the mFormula = line:
mFormula = _

Add Title to message box with several lines

I've got an about message box which when the user presses a button, a message box opens and prints information about the software, on several lines. In an attempt to make it look neater, I wish to remove the 'Microsoft Excel' title for the message box. What I did was I put two commas after the message, which I normally do, but with one line of text but I keep getting expression errors with an equals sign or an invalid syntax error. Could someone help?
Here's my current code :)
Private Sub about_button_Click()
MsgBox ("Name: gemUI" & vbCrLf & "Version: 1.0" & vbCrLf & "Build: 0001" & _
vbCrLf & "(C) 2018 Josh Face", , "About gemUI")
End Sub
If anyone could help, it would be greatly appreciated :)
Have a good evening :)
Josh
You have one too many parentheses. Ether take out the outside parenthesis surrounding the arguments or use the Call keyword.
Private Sub about_button_Click()
MsgBox "Name: gemUI" & vbCrLf & "Version: 1.0" & vbCrLf & "Build: 0001" & _
vbCrLf & "(C) 2018 Josh Face", , "About gemUI"
End Sub
or
Private Sub about_button_Click()
Call MsgBox( "Name: gemUI" & vbCrLf & "Version: 1.0" & vbCrLf & "Build: 0001" & _
vbCrLf & "(C) 2018 Josh Face", , "About gemUI")
End Sub
In VBA you call a subroutine with either
MySub arg1, arg2, arg3
or
Call MySub(arg1, arg2, arg3)
When you write
MySub (arg1, arg2, arg3)
it tries to combine the multiple arguments into one thing and it fails.
just to add a (maybe) less clumsy way:
MsgBox Join(Array("Name: gemUI", "Version: 1.0", "Build: 0001", "(C) 2018 Josh Face"), vbCrLf), , "About gemUI"

VBA Word: Property Revision.Style dosn't work

When I try to change some styles (e.g. textcolor) in a revisions object I get a Run-Time error '5852' (requested object is not available). I've used ActiveDocument.Revisions(i).Style ... Other properties are available (author, creator, type, ...). Btw: I really want change the style from the revision (not the ordinary text). Tested in Word 2010 & 2016
edit: a bit more detailed:
I try to change the color of the revisions that is displayed. Word sets it automically by default. But you can't choose which color Word assigns to reviewers (See this link)
Unfortunately this is exactly what I want to do. So I tried it with VBA and actually there is the property style available for the revision object, but I get an error 5852 in line with ActiveDocument.Revisions(i).Style
Sub test()
i = 1
While i <= ActiveDocument.Revisions.Count
Debug.Print "Revision " & i & " Author: " & ActiveDocument.Revisions(i).Author 'works
Debug.Print "Revision " & i & " Creator: " & ActiveDocument.Revisions(i).Creator 'works
Debug.Print "Revision " & i & " Date: " & ActiveDocument.Revisions(i).Date 'works
Debug.Print "Revision " & i & " FormatDescription: " & ActiveDocument.Revisions(i).FormatDescription 'works...
Debug.Print "Revision " & i & " Range: " & ActiveDocument.Revisions(i).Range 'work
Debug.Print "Revision " & i & " Style: " & ActiveDocument.Revisions(i).Style 'error 5852
Debug.Print "Revision " & i & " Type: " & ActiveDocument.Revisions(i).Type 'works
i = i + 1
Wend
End Sub
Does anyone know why this error occurs?
As you say, it's not possible to set the color for revisions per author, explicitly. It simply is not possible.
I believe that Revisions.Style is not for changing how a revision looks (color or anything else). I believe it's meant to return Style information, such as the name of the style and the various properties (analog to Range.Style). The error is because Word hasn't recorded such information, probably because it doesn't recognize the related style types...
There are two related(?) Revision.Type enums: wdRevisionStyle and wdRevisionStyleDefinition. In a quick test - formatting using a style, creating a style and changing a style definition - I was not able to return either of these revision types. But according to the Language Reference they mean:
wdRevisionStyle 8 Style changed.
wdRevisionStyleDefinition 13 Style definition changed.
In my tests, the type of revision returned for applying a style is wdRevisionParagraphProperty and changing a style definition is not recorded as a Revision.
For Revision.Style to return information I believe you'd need to test whether the Revision.Type is either of the above and only then would there be a valid object in Revision.Style.
I'm looking at Word 2010.

Using a saved report template and updating the Recordsource, then save to file

I'm trying to output reports. They all follow the same information, just for different managers. I can't seem to get any of the right syntax in to modify the necessary parts (Recordsource, Caption, and 1 field that will contain a set string). I don't know what its asking me and I can get the code to find the next manager name (a recordsource) and cycle through them. I can get the code to output to PDF file no problem. It's the relevant code below that I need to figure out. It's probably completely wrong. I haven't really dealt with reports yet.
DoCmd.OpenReport "rptUsageReportTemplate", acViewReport
Reports("rptUsageReportTemplate").RecordSource = MngrUsgRptStr
Reports("rptUsageReportTemplate").Caption = MngrName & "'s " & Mnth & " Usage Report"
Reports("rptUsageReportTemplate").Controls("fldManagerHeader") = MngrName & "'s " & Mnth & " Usage Report"
Reports("rptUsageReportTemplate").Requery
DoCmd.Close acReport, "rptUsageReportTemplate", acSaveYes
The "docmd.openreport" Is in there because i couldn't stop getting the error 2451 - The report name [...] you entered is misspelled or refers to a report that isn't open or doesn't exist." I know it exists and I know it's spelled correctly. So it must be an open thing. If I can get Access to output reports behind the scenes without needing to see the report open and close, that would be great.
In short what I want is for the Report I saved to be a template and just update the values a bunch of times and save it to file.
Assuming that you have a "Managers" Table or similar (tblManagersOrSuch) the following untested sub should get you going...
Sub DoManagersReport(Mnth As Integer)
Dim rsManagers As DAO.Recordset
Set rsManagers = CurrentDb.OpenRecordset("tblManagersOrSuch")
If Not rsManagers.EOF Then
rsManagers.MoveFirst
Do Until rsManagers.EOF
DoCmd.OpenReport "rptUsageReportTemplate", acViewPreview, , , acHidden
Reports("rptUsageReportTemplate").Caption = rsManagers!ManagerID & "'s " & Mnth & " Usage Report"
Reports("rptUsageReportTemplate").Controls("fldManagerHeader") = rsManagers!ManagerID & "'s " & Mnth & " Usage Report"
Reports("rptUsageReportTemplate").RecordSource = "Select * from MngrUsgRptStr Where ManagerID = " & rsManagers!ManagerID
DoEvents
Reports("rptUsageReportTemplate").Visible = True
DoCmd.OutputTo acOutputReport, "rptUsageReportTemplate", acFormatPDF, "C:\" & rsManagers!ManagerID & " " & Mnth & " Usage Report.pdf"
DoEvents
DoCmd.Close acReport, "rptUsageReportTemplate"
Loop
End If
'add error handling
End Sub
Note that setting the RecordSource forces a requery so you do not require that.
I would also suggest adding a fileSaveAs function to determine the save folder...

How to add a comment using comment boxes in Access?

I am building an Access database for work. I have set up a report to open upon click for a certain record. So only the information of that record is to appear on the report. However, I would like to add a comment box in the report where you can add comments. The new comments are stamped and added to the previous comments already showing in the report. I was able to program the commenting function in a separate report. However, for the reports that show only specific records it won't work. I know it is because I have to somehow add each comment to my database, but I just can not figure out how to do it. I used the following code that I found online in another article. It works fine when your comments are not tied to a certain record.
Private Sub cmdAppendComment_Click()
If (IsNull(txtNewComment.Value)) Then
MsgBox ("Please enter a comment before clicking" & _
"on the Append Comment button.")
Exit Sub
End If
' These commented lines will never be reached:
' If (IsNull(txtComment.Value)) Then
' Table.tblmain.User_comment.Value = txtNewComment.Value & " ~ " & _
' VBA.DateTime.Date & " ~ " & VBA.DateTime.Time
' Else
Table.tblmain.User_comment.Value = txtComment.Value & _
vbNewLine & vbNewLine & _
txtNewComment.Value & " ~ " & _
VBA.DateTime.Date & " ~ " & VBA.DateTime.Time
' End If
' txtNewComment.Value = ""
' Use Null:
txtNewComment.Value = Null
End Sub
You would use a form, not report, for this.
Bind this to the table, add the new comment to the existing comment bound to texbox, and save the record.