Hi, I'd like to embed Office documents in a GUI.
I found this code at:
https://autohotkey.com/board/topic/2915 ... anks-sean/
and
https://autohotkey.com/board/topic/2915 ... ntry186621
I'm using AutoHotkey_L, and the COM commands below throw errors.
I thought about downloading COM_L, but all the links are broken (including in the broken links reporting page) and it probably won't work anyway since COM is now built in.
I downloaded the old com.ahk lib and it didn't work, and I didn't really expect it to.
Can anyone point me in the right direction? Thanks!
GoSub, GuiOpen
pweb := COM_AtlAxCreateControl(WinExist(), A_Temp . "\test.xls")
pxlb := COM_Invoke(pweb, "Document") ; Excel Workbook
pxls := COM_Invoke(pxlb, "Worksheets", 1) ; Excel Worksheet
Return
GuiOpen:
Gui, +Resize +LastFound
Gui, Show, w800 h600 Center, Excel
COM_AtlAxWinInit()
Return
GuiClose:
Gui, Destroy
COM_Invoke(pxlb, "Save")
COM_Release(pxls)
COM_Release(pxlb)
COM_Release(pweb)
COM_AtlAxWinTerm()
ExitApp
;
Embed MS Office document in GUI Topic is solved
Re: Embed MS Office document in GUI Topic is solved
You can use dsoframer.ocx
Code: Select all
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
EnsureRegistered()
Gui, Add, ActiveX, w800 h600 vfc, DSOFramer.FramerControl
Gui, Show
fc.Menubar := false
fc.Toolbars := false
fc.Titlebar := false
; fc.Open(A_ScriptDir "\test.xlsx")
fc.CreateNew("Excel.Sheet")
fc.ActiveDocument.Sheets(1).Range("A1").Value := "test"
return
GuiClose:
ExitApp
EnsureRegistered() {
try {
ComObjCreate("DSOFramer.FramerControl")
} catch {
RunAsAdmin()
RunWait, regsvr32 /s dsoframer.ocx, %A_ScriptDir%
}
}
RunAsAdmin() {
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
}
DSOFramer functions
DownloadRe: Embed MS Office document in GUI
thank you , tmplinshi
this for PDF-file / or also for MP4
this for PDF-file / or also for MP4
Code: Select all
;_ ActiveX PDFx
xxa=Shell.Explorer ;- IExplorer
;xxa=Mozilla.Browser ;- firefox no success
F1=C:\test.pdf
stringreplace,f1,f1,\,/,all
F2:="file:///" . F1
Gui Add, ActiveX, w980 h750 vWB1,%xxa%
WB1.Navigate(F2)
Gui, Show,x0 y0 w1024 h768, TEST-PDF
return
Guiclose:
exitapp
Re: Embed MS Office document in GUI
Thanks to both. No joy yet. Tmplinshi, when I run your code everything that is "fc.*" throws an error.
I already have dsoframer.ocx registered on my system from another program, but tried re-registering it also (though EnsureRegistered() didn't throw an exception).
When I refresh the webpage that displays, I get this message: "Make sure the web address http://dsoframer.framercontrol is correct".
I do feel the code is close to working, though.
I have test.xlsx in the script dir, of course.
Garry, thank you, I'm having trouble with that one too, of a different nature: the PDF downloads with a dialog box (Open or Save), both of which work but neither of which show the pdf in the GUI. Save calls up the file dialog, and Open just opens it in Acrobat.
Thanks again, I look forward to more input.
I already have dsoframer.ocx registered on my system from another program, but tried re-registering it also (though EnsureRegistered() didn't throw an exception).
When I refresh the webpage that displays, I get this message: "Make sure the web address http://dsoframer.framercontrol is correct".
I do feel the code is close to working, though.
I have test.xlsx in the script dir, of course.
Garry, thank you, I'm having trouble with that one too, of a different nature: the PDF downloads with a dialog box (Open or Save), both of which work but neither of which show the pdf in the GUI. Save calls up the file dialog, and Open just opens it in Acrobat.
Thanks again, I look forward to more input.
Re: Embed MS Office document in GUI
@burque505 , I have the same problem with PDF when I use Mozilla.Browser , Shell.Explorer works for me , maybe see settings in browser for extensions
tmplinshi's script works for me , but I use Open-Office and Microsoft-Office asks me for Product Key ... I can refuse , then with restricted functions ( I want only read )
tmplinshi's script works for me , but I use Open-Office and Microsoft-Office asks me for Product Key ... I can refuse , then with restricted functions ( I want only read )
Last edited by garry on 13 Feb 2017, 14:35, edited 1 time in total.
Re: Embed MS Office document in GUI
Thanks, Garry. I wonder what I'm doing wrong with tmplinishi's script? I just copied and pasted it.
Maybe my version of dosframer.ocx doesn't work with AHK, but it works fine with the application it came with. I'll look for a 64-bit version (my OS is 64-bit) and see if maybe that's the problem.
I appreciate your input.
Maybe my version of dosframer.ocx doesn't work with AHK, but it works fine with the application it came with. I'll look for a 64-bit version (my OS is 64-bit) and see if maybe that's the problem.
I appreciate your input.
Re: Embed MS Office document in GUI
Just found a reference on the web saying dsoframer.ocx doesn't support Office 2010. I'm using Office 2016, maybe that's the problem.
Or not. I downloaded and installed the official sample pack, and the samples work fine. I also copied that dsoframer.ocx over to the script directory, still no luck.
Or not. I downloaded and installed the official sample pack, and the samples work fine. I also copied that dsoframer.ocx over to the script directory, still no luck.
Re: Embed MS Office document in GUI
My environment:
Try add following code to the top of the script.
- AutoHotkey v1.1.24.05 Unicode 32-bit
- Office 2016
- Windows 64-bit
Try add following code to the top of the script.
Code: Select all
If (A_PtrSize = 8) {
MsgBox, 48,, Please use 32-bit AutoHotkey
ExitApp
}
RunAsAdmin()
RunWait, regsvr32 /s dsoframer.ocx, %A_ScriptDir%
Re: Embed MS Office document in GUI
Here is a way to Registration-Free by using manifest file.
dsoframer.manifest:
Download
dsoframer.manifest:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><file name="dsoframer.ocx" hashalg="SHA1"><comClass clsid="{00460182-9E5E-11D5-B7C8-B8269041DD57}" tlbid="{00460180-9E5E-11D5-B7C8-B8269041DD57}" description="DSO Framer Control Object"></comClass><typelib tlbid="{00460180-9E5E-11D5-B7C8-B8269041DD57}" resourceid="1" version="2.2" helpdir=""></typelib></file><comInterfaceExternalProxyStub name="_FramerControl" iid="{00460181-9E5E-11D5-B7C8-B8269041DD57}" tlbid="{00460180-9E5E-11D5-B7C8-B8269041DD57}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub></assembly>
Code: Select all
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
If (A_PtrSize = 8) {
MsgBox, 48,, Please use 32-bit AutoHotkey
ExitApp
}
RegCOM("dsoframer.manifest")
Gui, Add, ActiveX, w800 h600 vfc, {00460182-9E5E-11D5-B7C8-B8269041DD57}
Gui, Show
fc.Menubar := false
fc.Toolbars := false
fc.Titlebar := false
; fc.Open(A_ScriptDir "\test.xlsx")
fc.CreateNew("Excel.Sheet")
fc.ActiveDocument.Sheets(1).Range("A1").Value := "test"
return
GuiClose:
ExitApp
RegCOM(ManifestFile) {
VarSetCapacity(actctx, 34, 0)
NumPut(34, actctx, 0, "UInt")
NumPut(&ManifestFile, actctx, 8, "UInt")
hActCtx := DllCall("CreateActCtx", "ptr", &actctx, "ptr")
if (hActCtx = INVALID_HANDLE_VALUE := -1) {
throw, "INVALID_HANDLE_VALUE"
}
DllCall("ActivateActCtx", "ptr", hActCtx, "ptr*", cookie)
}
Last edited by tmplinshi on 04 Apr 2017, 02:52, edited 1 time in total.
Re: Embed MS Office document in GUI
tmplinshi, you are the greatest!
It was in fact me running a 64-bit AHK. The 32-bit version I swapped in runs both versions you provided perfectly.
Fantastic. Wonderful. And thanks for working .ocx, of course.
Regards and the highest of praise,
Burque505.
It was in fact me running a 64-bit AHK. The 32-bit version I swapped in runs both versions you provided perfectly.
Fantastic. Wonderful. And thanks for working .ocx, of course.
Regards and the highest of praise,
Burque505.
Re: Embed MS Office document in GUI
Excuse me, this verison doesn't work for me. My environment is winXP sp3 chs, ahk_l u32.tmplinshi wrote:Here is a way to Registration-Free by using manifest file.
It seems that the classid and progid still can't be recognized by ahk.
The activex control in the GUI becomes IE ( maybe dsoframer is based on IE?)
What's wrong? Can u help me?
Re: Embed MS Office document in GUI
@hughman Are you using the lastest version of AHK? If not try updating first.
No, any invalid components name will become "IE". e.g. : Gui, Add, ActiveX, w300 h300, testhughman wrote:The activex control in the GUI becomes IE ( maybe dsoframer is based on IE?)
Re: Embed MS Office document in GUI
I get it. if ahk is located in another computer of LAN, it failed.But the local ahk can make it run. Is it posdible to be solved?tmplinshi wrote:@hughman Are you using the lastest version of AHK? If not try updating first
btw: Do you have a solution for x64 system? the dsoframer seems too old.
at last, thanks for you good idea and help.
Re: Embed MS Office document in GUI
You can use 32-bit AHK on x64 system.hughman wrote:btw: Do you have a solution for x64 system? the dsoframer seems too old.
To use dsoframer on 64-bit AHK, you will need 64-bit version of dsoframer.ocx, but such version doesn't exist on the internet.
Who is online
Users browsing this forum: No registered users and 286 guests