I am messing around with some Visio VBA in 2010 standard.
Any method or property I try with a recordset object gives an error.
Public Sub LinkAllRecordsets()
Dim drs As Visio.DataRecordset
Dim dcn As DataConnection
Dim doc As Document
Dim intCount As Integer
intCount = ThisDocument.DataRecordsets.Count
End Sub
The debug halts at the intCount = line, giving a generic "this operation is not supported in Microsoft Visio Standard 2010".
Is there a way I can get around this?
Thanks.
No way! DataRecordsets are supported only in Visio 20xx (2007+) Professional or Visio Plan 2 editions!
DataRecordset object
Nuts!
Thanks for the information.
Related
I'm learning VS VB, so please forgive the ignorance.
I have built a form that accepts a file search pattern, searches for matching files and then displays the file names (up to 10) in text boxes.
If you double click on the file name (up to 10) text box, I want it to call a routine to open Powerpoint and display the first slide.
I've searched around and can't find any information thats helpful to me for 2017.
At this point, my code looks like below (just shows that I have the full file name).
Public Sub DisplaySong(ByVal SongFileName)
Dim SongToDisplay As String = ""
Dim i As Integer
' get the full song path/name
Try
Dim strFiles As String() = Directory.GetFiles(strSearchPath.ToString, SongFileName.ToString, IO.SearchOption.AllDirectories)
i = 0
' should never be more than 1 song
For Each SongFileName In strFiles
SongToDisplay = strFiles(i)
i = i + 1
Next
Catch ex As Exception
MessageBox.Show("Error processing Display Song: Finding Song!! ")
End Try
MessageBox.Show("Song Selected: " + SongToDisplay.ToString)
End Sub
The examples I've talk about adding the COMs, but I don't see "Microsoft Graph Object Library" in the 2017 version. I selected MS PowerPoint and the MS Graph 14.0, thinking (hoping) that's what I needed.
When I add
Dim oApp as PowerPoint.Application
into the subroutine, I get the error message that it's not defined. I know how to do this in Access VB 2010, but I don't know how to do this in VS VB 2017.
Any help is appreciated.
Dummy me. Adding
Imports Microsoft.Office.Interop
Fixed the problem.
I maintain an Access DB that I built a few years ago when Office 2010 (32bit) was the standard. We've recently upgraded to Office 365 (also 32bit). This db is very dependent on using Me.Recordsetclone to do stuff. For example:
Private Sub Form_Unload(Cancel As Integer)
Dim rst As ADODB.Recordset
Set rst = Me.RecordsetClone
'Do stuff
End Sub
Now that Office has been upgraded, when the code calls Me.RecordSetClone, the 'Select Data Source' Dialog box shows up. When I try out the same code on an RDP we having running 2010, it works normally. Based on that and what little I can find on the net, I think it's a library switching/version issue.
The only work-around I can think of is to have the users run both versions side-by-side and switch back and forth. But that would be a maintenance headache. Can anyone suggest a better alternative?
I've never seen ADO used for this, only DAO:
Private Sub Form_Unload(Cancel As Integer)
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
'Do stuff
End Sub
I have had the same issue and seem to have rectified by changing my recordset clone reference from
Me.*Subform*.Form.RecordsetClone
to the following
Set Rst = Forms!*Mainform*.Form!*Subform*.Form.Recordset.Clone
I hope this helps.
I wrote a VBA script for Outlook 2010. The purpose of this script is to clean some elements from the tasks and contacts for the user. This needs to be done following a migration to a new client managing solution. Since Exchange is connected to the new solution some items are doubled so we need to delete the items from outlook. Ideally this would be done on the Exchange server but we don't have access to it directly...
My script is already working but my problem lies with the distribution of said script. We don't have direct access to the computers of these people so what we need is a way to package it in a download, have them run it once from a link in an email and forget about it. Most of these users have about zero computer knowledge. Ideally I don't want this script to remain in Outlook after that one execution.
I searched for a solution but found nothing...
Here's my script if that helps. Also, I'm not a good programmer... So if there's a better way to do this don't hesitate to tell me.
Private Sub CleanUp()
Dim TaskFolder As Folder
Set TaskFolder = Session.GetDefaultFolder(olFolderTasks)
Dim Task As TaskItem
Dim objProperty As Outlook.UserProperty
Dim uProperty As String
Dim collTasks As New Collection
Dim ContactFolder As Folder
Set ContactFolder = Session.GetDefaultFolder(olFolderContacts)
Dim Contact As ContactItem
Dim objPropertyCLS As Outlook.UserProperty
Dim uPropertyCLS As String
Dim collContacts As New Collection
uProperty = "crmxml"
uPropertyCLS = "crmLinkState"
For Each Task In TaskFolder.Items
Set objProperty = Task.UserProperties.Find(uProperty, Outlook.OlUserPropertyType.olText)
If objProperty Is Nothing Then
Debug.Print "objProperty is Nothing"
ElseIf InStr(objProperty, "phonecall") > 0 Then
collTasks.Add Task
ElseIf InStr(objProperty, "letter") > 0 Then
collTasks.Add Task
ElseIf InStr(objProperty, "fax") > 0 Then
collTasks.Add Task
End If
Next
For Each Contact In ContactFolder.Items
Set objPropertyCLS = Contact.UserProperties.Find(uPropertyCLS, Outlook.OlUserPropertyType.olNumber)
If objPropertyCLS Is Nothing Then
Debug.Print "objPropertyCLS is Nothing"
ElseIf Not objPropertyCLS Is Nothing Then
collContacts.Add Contact
End If
Next
For Each Task In collTasks
Task.Delete
Next
For Each Contact In collContacts
Contact.Delete
Next
End Sub
Thanks a lot!
VBA scripts were not designed for deploying them on multiple PCs. If you need to run your code on multiple PCs you have to develop an add-in instead. Add-ins can be installed by users easily like any other Windows programs. If the add-in is not required any longer, it can be un-installed or disabled from the COM add-ins dialog in Outlook. See Walkthrough: Creating Your First VSTO Add-In for Outlook to get started quickly.
I know that there are tons of versions in JavaScript out there but I need this as a vb version for use in Scripting in Exel 2010? Has anyone done this translation?
If your query is for XML DOM methods, , then in the VB Editor in Tools > References add a reference to Microsoft.MSXML2
goto 1) below!
If your query is for DHTML DOM methods, then in the VB Editor in Tools > References add a reference to Microsoft.mshtml
1) Then you can access the DOM using all the methods that you see in the Object Browser (keystroke f2 in the VB Editor, then select MSHTML in the drop down to select DHMTML DOM Library.
an example using MSXML would be:
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("title")[0]
y=x.childNodes[0]
msgbox y.nodeValue
an example (using MSHTML) would be :
Sub testDoc()
Dim xDoc As MSHTML.HTMLDocument
Dim sURL As String
Dim oElement As MSHTML.HTMLBaseElement
Set xDoc = New MSHTML.HTMLDocument
With xDoc
.Open (sURL)
Set oElement = .getElementById(idName)
MsgBox oElement.ID
End With
End Sub
I hope that gets you started in the right direction.
BTW,
Philip
the following two lines
Dim curTasks As Tasks
Set curTasks = Application.Tasks
get the list of all current tasks and work like charm in vba-word but not in vba-excel.
is there a way to port it into vba-excel?
As I said in comments, the Excel object in VBA doesn't have the concept of tasks. You can do the below though in an Excel Module (although I'm still not sure why you would do it):
Dim curTasks As Tasks
Dim wrd As Word.Application
Set wrd = CreateObject("Word.Application")
Set curTasks = wrd.Tasks
NOTE: you have to add a reference to Microsoft Word Object Library to get this to work