Jump to content

Search the Community

Showing results for tags 'vba'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 15 results

  1. Hello Forum! I have a Word VBA Macro that inserts an image. I rebuilt the same behavior in AutoIt. Everything works the same except of one tiny difference. In VBA the image does NOT move down when i manually press <ENTER> after the Macro was running. In Autoit the image DOES move down when i press <ENTER> after the Script was running. Adding the image is just the beginning of the script. More Text will be added after. When i press <END> and then <ENTER> the behavior is the same again as in VBA. I tryd already several things but i do not want to hack in a Send("{END}") VBA: ' LOGO ---------------------------------------------------------------------------------------------------------------------- Dim Img As String Dim inlineShape As inlineShape Dim shape As shape Img = "C:\Logo.png" Set inlineShape = Selection.InlineShapes.AddPicture(FileName:=Img, LinkToFile:=False, SaveWithDocument:=True) inlineShape.LockAspectRatio = msoTrue inlineShape.width = CentimetersToPoints(9.58) Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter Set shape = inlineShape.ConvertToShape shape.WrapFormat.Type = wdWrapMergeFront ' Set wrapping type to "Top and Bottom" < This is not wrong! ' Texts ------------------------------------------------------------------------------------------------------------------------ Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft Selection.ParagraphFormat.SpaceAfter = 10 'Selection.TypeParagraph AutoIt: #include <Word.au3> #include "WordConstants.au3" Global $oRange Global Const $wdAlignParagraphCenter = 1 ; Align Center Global Const $wdAlignParagraphLeft = 0 ; Align Left Global Const $wdWrapMergeFront = 4 ; In front of Text Global $Bild = @ScriptDir & "\Logo.png" Global $oWordApp = _Word_Create(); Start Word Global $oDoc = _Word_DocAdd($oWordApp); Create Document Global $oInlineShape = $oDoc.InlineShapes.AddPicture($Bild, False, True) $oInlineShape.LockAspectRatio = True $oInlineShape.width = CentimetersToPoints(9.58) $oRange = $oInlineShape.Range $oRange.ParagraphFormat.Alignment = $wdAlignParagraphCenter ; Center Global $oShape = $oInlineShape.ConvertToShape ; Convert InlineShape to Shape $oShape.WrapFormat.Type = $wdWrapMergeFront ; Set wrapping type to "Top and Bottom" < "MergeFront" selects "Top and Bottom" in Word $oRange = _Word_DocRangeSet($oDoc, 0) $oRange.ParagraphFormat.Alignment = $wdAlignParagraphLeft ; Align Left $oRange.ParagraphFormat.SpaceAfter = 10 ;$oWordApp.Selection.TypeParagraph ;$oRange.InsertAfter("Inserted text after range.") ;$oRange.EndKey($wdLine,0) ;$oRange.Text = @CRLF ;$oRange.Collapse($wdCollapseEnd)
  2. Excel VBA's IDE registers a Control-y as "cut this line of code". For those prone to Undo/Redo (Ctrl+Z/Ctrl+Y) you may find frustration when your code in the editor does not redo, but in fact clears your active line of code while killing redo history. Though not perfect, I keep this tool running in background on startup. The purpose is to allow Cltr+Y to act normally throughout Windows and Office and only interact *differently* with the "Microsoft Visual Basic for Applications" window that is active. If the Standard Menu bar exists, it'll try to click the ReDo (Blue Arrow to the right), else "Alt+e, r" keystrokes (less desired). Here's the code: Opt('MustDeclareVars', 1) Opt("WinTitleMatchMode", 1) HotKeySet("^y", "TriggerRedo") While 1 Sleep(10) WEnd Func TriggerRedo() ConsoleWrite("TriggerRedo()" & @CRLF) Local $title = "Microsoft Visual Basic for Applications - " Local $hWnd If WinExists($title) And WinActive($title) Then ;~ Parent Window Handle $hWnd = WinGetHandle($title) Local $aWindowPos = WinGetPos($hWnd) ;~ Control Bar Handle, Position and If Visible Local $sControlID = "[CLASS:MsoCommandBar; TEXT:Standard;]" Local $hStandardBar = ControlGetHandle($hWnd, "", $sControlID) Local $bIsVisible = ControlCommand($hWnd, "", $sControlID, "IsVisible") If $hStandardBar And $bIsVisible Then ConsoleWrite("Using Mouse Click." & @CRLF) ;~ Determine Redo button location on visible Control Bar Local $aBarPos = ControlGetPos($hWnd, "", $sControlID) Local $mX = $aWindowPos[0] + $aBarPos[0] + 217 + Int(23/2) Local $mY = $aWindowPos[1] + $aBarPos[1] + 27 + Int(22/2) MouseClick("Left", $mX, $mY, 1, 0) Else ConsoleWrite("Using VBA Send Keys." & @CRLF) $sControlID = "[CLASS:MsoCommandBar; TEXT:Menu Bar;]" Local $hMenuBar = ControlGetHandle($hWnd, "", $sControlID) ControlSend($hWnd, "", $hMenuBar, "!e") ;~ Send("r") $sControlID = "[CLASS:MsoCommandBarPopup; TEXT:Edit;]" Local $hPopupBar = ControlGetHandle($hWnd, "", $sControlID) ControlSend($hWnd, "", $hPopupBar, "r") EndIf Else ConsoleWrite("Using NATIVE Send Keys." & @CRLF) HotKeySet("^y") Send("^y") ;~ may cause "yyy..." when held HotKeySet("^y", "TriggerRedo") EndIf EndFunc ;==>TriggerRedo Hope this inspires someone.
  3. Good morning Forums In these days, I am working on a project that involved me to use some Windows APIs to obtain some information about Terminal Servers. I'm doing this using wtsapi32.dll in a VBA Project, but, the lack of knowledge about few things threated in the articles make this quite difficult to implement and understand at the same time. The most difficult thing I'm facing is "translating" C/C++ functions or struct in VBA when pointers are used, or pointers of pointers, and so on. Since VBA seems to not have a pointer type, to make those functions work I need to implement other functions taken from other DLLs, and this confuses me a lot. For example, starting from this code, I splitted all the functions and all the definitions to understand why they are there, and why I need to use them. At the end, I've found out that the code I was going to implement starting from the functions provided in the Microsoft Docs won't be ever be able to work without some supplementary functions which are not mentioned anywhere. So, I was wondering if someone would please point me out to a good and practical exaplanation about pointers (in general) or specifically for VBA, because I need to use them quite often in these days, and I'd like to understand what I am doing. Thanks in advance. Best Regards and Stay at home 🏡
  4. Hi all, I'm trying to write a script that connects with a VBA/COM API to get the status of a connected phone. I've been looking up and down this forum for tips or other user's experiences, but I can't seem to find anything (even remotely) similar. It shouldn't be so hard to do, however. Software I'm trying to connect to I'm trying to integrate CallCenter by using their API, which is documented over here : JustRemotePhone API Reference Things I've tried I've tried using ObjCreate but I don't get any result, it always returns the same (negative) error. #Version 1 tried ObjCreate("JustRemotePhone.RemotePhoneService") #Version 2 tried ObjCreate("JustRemotePhoneCOM.RemotePhoneService") #Version 3 tried ObjCreate("JustRemotePhoneCOM.RemotePhoneService.Application") None of the three versions I tried seem to deliver any result other than a negative error value which basically says that the given class is not valid. I am starting to get the hang of AutoIt by now, but unmanaged programming languages and object-oriented stuff is still quite a grey zone for me. If anyone could help me 'talk' to this application, I'd be immensely grateful! Thanks in advance and kind regards from Belgium! Jan
  5. How do I properly convert this to Autoit? This is a VBA macro that I recorded in Excel.  ActiveSheet.Outline.ShowLevels RowLevels:=2 I need this to close my subtotal once it is finished. any help will be greatly appreciated.
  6. I am using Autoit to automate another software. I am looking to create a piece of code which can select the option from a combo box. I know what option I want to select and I have stored it in a string but nothing seems to be working for me. I am able to click on the Control by using this code. ControlClick("Import/Export Table Name", "","[NAME:cmbTableName]"); This is what I was thinking but doesn't work for me. ControlCommand("Import/Export Table Name", "", "[NAME:cmbTableName]", "SelectString", $MyOptionName) If it helps: The option name that I want to select is also stored in clipboard. Any comments on what am I missing here will be appreciated. Thanks
  7. Hi, I am trying to use ControlMove function AU3 DLL in VBA. The function instead of moving the control just makes it disappear. It only appears when I resize notepad manually. Can anybody please help me and let me know whats the miss here Here's the code I am working on: Private Declare PtrSafe Function AU3_ControlMove Lib "C:\Program Files\AutoIt3\AutoItX\AutoItX3.dll" (ByVal szTitle As LongPtr, ByVal szText As LongPtr, ByVal szControl As LongPtr, ByVal nX As Integer, ByVal nY As Integer, nWidth As Integer, nHeight As Integer) As Long Private Function ControlMove(szTitle As String, szControl As String, nX As Integer, nY As Integer, Optional nWidth As Integer = -1, Optional nHeight As Integer = -1, Optional szText As String = "") As Long ControlMove = AU3_ControlMove(StrPtr(szTitle), StrPtr(szText), StrPtr(szControl), nX, nY, nWidth, nHeight) End Function Sub test() ControlMove "Untitled - Notepad", "[CLASS:Edit; INSTANCE:1]", 0, 0, 150, 150 End Sub The Edit Box in Notepad just disappears.
  8. Hi, I want to send text into a VBA form's text field. Can someone please guide me on the autoit script that can help me. Below is the sample code that I need help on: #include <Excel.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> @ScriptDir ="D:\\AutoIT\" $sFilePath = @ScriptDir & "\ExcelForm.xlsm" Local $oAppl = _Excel_Open() ;Local $oAppl = _Excel_Open(False, Default, Default, Default, True) Local $sWorkbook = $sFilePath Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook) ConsoleWrite('before opening macro.........1') $oAppl.Run('mymacro') Sleep(3000) ConsoleWrite('After opening macro.........1') Send('First text') ConsoleWrite('After opening macro.........2') Send('{TAB}') ConsoleWrite('After opening macro.........3') Send('Second text') ConsoleWrite('After opening macro.........4') Send('{TAB}') Send('{Enter}') ConsoleWrite('After opening macro.........5') thanks,
  9. Hi, Can someone help me with how to translate this correctly? I've been working on it for a few hours and I just can't quite get it right. Columns("G:G").Select Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _ Formula1:="=""Purchase""" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(1).Font .Color = -16383844 .TintAndShade = 0 End With With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .Color = 13551615 .TintAndShade = 0 End With Selection.FormatConditions(1).StopIfTrue = False I think I'll be fine after the .Add line, I just cannot get it to work. Here's what I've been trying: $oExcel.Selection.FormatConditions.Add(9, 3, "=""Purchase""", '') ;Type:=xlCellValue, Operator:=xlEqual, Formula1:="=""Purchase""" Any help is definitely appreciated!
  10. I'm trying to create a simple outlook function that validates the email addresses before sending. I'm trying adapt this script: https://msdn.microsoft.com/EN-US/library/office/ff867165.aspx Func SendEmails() $olApp = ObjCreate("Outlook.Application") $olMailItem = 0 $objMail = $olApp.CreateItem($olMailItem) With $objMail .Save .Subject = ("TEST") .Display $oRecipients=.Recipients EndWith With $oRecipients .Add("User1") .Add("User2") If not .ResolveAll Then For $z In $oRecipients If not .Resolved then MsgBox(0,"",.Name) Next EndIf EndWith EndFuncI'm only trying to capture the message box because the resolveall function doesn't seem to be doing anything. I tried using the above script and it works up to the resolveall statement but it doesn't seem to do anything. I was hoping putting the message box in would help me figure out what is going on, but I'm getting errors on .Resolved. Anyone used the Resolveall function before?
  11. I am restating a topic that was not solved from >here (I am not sure what are the rules of restarting a already discussed topic) I am using the following code in VBA to run Autoitcode.au3 file.
  12. I am using the following code in VBA to run Autoitcode.au3 file. Sub RunFileName() Dim runscript Dim FileName As String FileName = ThisWorkbook.Path & "\Autoitcode.au3" MsgBox (FileName) runscript = Shell("C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe " & FileName) End Sub The Autoit code I want to run, works fine when I directly run by double clicking the file in folder, but when I use this VBA code it gives me error of Autoit Line 0 Error ("File: E:\Data\Point") Error : Error Opening the file Actually this line should be reading this path: E:\Data\Point Data\Folder\Folder\My File.xlsm So, executing Autoit code from VBA is not reading the SPACE in between the folder name Point Data and hence not reading the full path. Otherwise running directly by clinking the autoit file its running smoothly. So is there a way I can run my Autoitcode from VBA without this unreadable space in folder names problem. Thankyou
  13. I have done extensive programming in vb vba and autoit. Currently, I have a fairly complex application using word, autoit compiled exe's and vba. Various functions in my application shell to dos and run various autoit scripts that have been compiled into 'exe's. Calling a function in the autoitx dll has to be faster and cleaner. I have been just told in the autoit forum about autoitx. If I could just see sample code for autoitx and how to call it from vba I think I can run with it and figure out everything I need to do. Let's say I want autoitx to get the name of a window to activate (from vba) and use "WinActivate" to activate it. Thanks mucho
  14. This is what is needed to use AutoItX3 Dll in Word VBA 1. Check the checkbox in references for Autoit type Lib 2. Diminsion a variable to use as the parent for all AutoIt functions. EG: Dim AutoIt As New AutoItX3Lib.AutoItX3 3. Type the parent name followed by a dot. You will right away see a drop down list of Autoit functions. 4. Select the function needed. The syntax is different in VBA for word. EG: In the Scite editor you would use the WinActivate like so: WinActivate("My Window", "Text in the window") In VBA for Word (and all other office products probably) you use: AutoIt.WinActivate "My Window", "Text in the window" 'No parens Otherwise "Expected Function or Variable" is encountered. My only question now is why is the list of functions in the drop down only a small subset of the bizillion functions that exit in Autoit.
  15. I am developing some excel export code. A small part is outputting some constants not in the excel UDF. I can find the constant using VBA editor from Excel. But my question is basically (since it did not work in AutoIT): In terms of VBA code, which object type is $oExcel in this code: Local $oExcel = _ExcelBookOpen(@ScriptDir & "\" & "tstfile.xlsx", 1) I tried to do this: ; VBA CODE which works Sub s() MsgBox Application.ThisWorkbook.FullName End Sub personally I think $oExcel is an application object, so this should work: ConsoleWrite("From Excel file : " & $oExcel.ThisWorkbook.FullName & @CRLF) .. but it does not. What am I missing here ? Normally I know my way in and out of VBA etc.
×
×
  • Create New...