this code is use to convert PDF to excel.
But a problem was found during the compilation. The error message getting is "Compile Error: Invalid use of new keyword" at line "Set AC_PD = New Acrobat.CAcroHiliteList". I have no idea to fix this and had many try on this. I need some advise, guidance from you. Appreciated and Thank you.
Private Sub ABC()
Dim AC_PD As Acrobat.CAcroPDDoc
Dim AC_Hi As Acrobat.CAcroHiliteList
Set AC_PD = New Acrobat.CAcroPDDoc
Set AC_Hi = New Acrobat.CAcroHiliteList
'...
End Sub
Judging by a cursory look at the documentation, it looks like their COM interfaces might be a little jacked up. Try this instead:
Set AC_PD = CreateObject("AcroExch.PDDoc")
Set AC_Hi = CreateObject("AcroExch.HiliteList")
The typedef names are on page 19.
Related
Looking for help on how to implement VBA code to check if an element exists or explicitly waiting for it in VBA. Here is a small sample code I am testing out. The below code gives an error while running since it says "Object Required"
Dim Driver As New ChromeDriver
Driver.get "Test website"
If Driver.IsElementPresent(By.XPath("/html/body/div[2]/div/div[5]/h3"))) Then
Debug.Print("Yes")
Else
Debug.Print("No")
I even have tried changing the .IsElementPresent to this line of code so I can test the size of the element if it exists but receiving an error that "NoSuchElementError"
Debug.Print (browser.FindElementByXPath("/html/body/div[2]/div/div[5]/h3").Size())
Seem to work for me. The only issue I am seeing in your code is that you didn't declare By anywhere.
e.Start isn't a requirement, but I do it anyway.
So I would try declaring By and see what happen there. And you need to set it as a new instance, a simply type-declaration won't work, which means:
Just using Dim By As Selenium.By is NOT enough, but either of these lines:
Dim By As New Selenium.By
or
Dim By As Selenium.By
Set By = New Selenium.By
The Object Required error you are receiving is likely due to the missing declaration I stated above.
As text above, for me it worked like this...
Dim ch As Selenium.ChromeDriver
Set ch = New Selenium.ChromeDriver
'... all code ...
If ch.IsElementPresent(FindBy.XPath("//*[#id='div_footer']/table/tbody/tr/div")) Then
ch.FindElement(FindBy.XPath("//*[#id='div_footer']/table/tbody/tr/div")).Click
ElseIf ch.IsElementPresent(FindBy.XPath("//*[#id='xlsbutton']")) Then
ch.FindElement(FindBy.XPath("//*[#id='xlsbutton']")).Click
Else
'nohing here, only to understand stament
boolean_check_Download_Click_XYZ = false
End If
small problem here but can't seem to find the solution :(
DOMDocument in VBA is not loading properly, remains empty.
Not even giving an error if a non-existent file is used.
Any ideas?
Many thanks in advance.
Dim MyDom As MSXML2.DOMDocument60
FILEL = <XML FILE LOCATION IS PLACED HERE>
Set MyDom = CreateObject("MSXML2.DOMDocument.6.0")
MyDom.Load (FILEL)
Debug.Print (MyDom.XML) 'RETURNS nothing
As a side note: Don't mix early and late bound for the same object. If using early bound then
Dim MyDom As MSXML2.DOMDocument60
Set MyDom = New MSXML2.DOMDocument60
Then some basic checks:
MyDom.async = False
MyDom.validateOnParse = True
If Not MyDom.Load("path") Then
MsgBox "Problem"
Exit Sub
End If
I am struggling with a piece of code that places a custom class in a collection. Every time I run the code I get a runtime error 91. The error is occuring on the Set pjt = New CProject line.
Dim Projects As Collection
Private Sub BuildProjects()
Dim pjt As CProject
Set Projects = New Collection
Set pjt = New CProject '<-----ERROR OCCURS HERE
'Do some other stuff
End Sub
This is obviously the simplest form of the Sub, but it still throws the error! What am I doing wrong? Do I need to set the access for the CProject class file somehow?
All your help will be greatly appreciated.
The line Set pjt = New CProject is calling the constructor for CProject.
The error will most likely be in the constructor of CProject.
Error 91 is a null reference
I am trying to create a custom tool in VB.Net for arcmap. But im having a problem with FeatureCursor passed to ISelectionSet's Search() method.
Here's a portion of my code:
Dim pSelSet As ISelectionSet = provFSel.SelectionSet
Dim provCursor As IFeatureCursor
pSelSet.Search(spatialFilter, True, provCursor)
Dim provFeature As IFeature = provCursor.NextFeature
A blue squiggle appears under provCursor inside Search() that says "Variable 'provCursor' is passed by reference before it has been assigned a value. A null reference exception could result at runtime."
Ive tried
Dim provCursor As IFeatureCursor = New FeatureCursor
but a squiggle under New FeatureCursor says "'ESRI.ArcGIS.Geodatabase.FeatureCursorClass.Friend Sub New()' is not accessible in this context because it is 'Friend'.".
I also tried
Dim provCursor As IFeatureCursor = Nothing
but with no success.
In all my debugging attempts, Arcmap crashed with this error: A first chance exception of type 'System.NullReferenceException' occurred in Microsoft.VisualBasic.dll
Can somebody help me figure out whats wrong with my code? Ill really appreciate any help.
-spearman
Im not actually sure if error occurs in the above codes or in the prior codes. Im therefore posting the whole subprocedure content:
Dim pPoint As IPoint = pMxDoc.CurrentLocation
Dim provFSel As IFeatureSelection = provinceLayer
Dim pGeom As IGeometry = pPoint.Shape
Dim spatialFilter As ISpatialFilter = New SpatialFilter
With spatialFilter
.Geometry = pGeom
.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin
End With
Dim pSelSet As ISelectionSet = provFSel.SelectionSet
Dim provCursor As IFeatureCursor
pSelSet.Search(spatialFilter, True, provCursor)
Dim provFeature As IFeature = provCursor.NextFeature
Try:
pSelSet.Search(spatialFilter, True, out provCursor)
I want to get the following working, please could someone advise...
Dim rpt As ReportDocument
If (Exists(rpt.ReportDefinition.ReportObjects("crlTitle"))) Then
txtTitle = CType(rpt.ReportDefinition.ReportObjects("crlTitle"), TextObject)
txtTitle.Color = mainColour
txttitle.Text = "Report Title"
End If
Any help much appreciated.
I've never done anything like that...I'm not sure if it's possible. What will work for sure though is to use a parameter to control the report title. Simply create a parameter and then rpt.SetParamterValue("title", "Some Title")
Since you've identified the problem as "Exists is undefined". Addressing that problem is more straightforward. Try replacing the "Exists" line with:
If (rpt.ReportDefinition.ReportObjects.Contains("crlTitle")) Then
Were there any other problems?
Here is my solution:
Dim rpt as ReportDocument
Dim rptTextObject as TextObject = nothing
Dim mainColour As Color = Color.Green
Try
If (rpt.ReportDefinition.ReportObjects("crlTitle") IsNot Nothing) Then
rptTextObject = CType(rpt.ReportDefinition.ReportObjects("crlTitle"), TextObject)
rptTextObject.Color = mainColour
rptTextObject.Text = "Report Title"
End If
Catch
End Try
I do this for each Object on the report that I want to either set text or set colour.
Put this line of code at the beginning of the module
Imports System.IO.File