Beste mensen,
Graag verzoek ik om jullie help bij de volgende macro:
het gaat om de onderstreepte en zwartgedrukte regel. VBA blijft zeggen dat er een fout in die regel van de macro zit, maar ik zelf kom er niet uit; wat dit precies is. kunnen jullie mij misschien helpen?
Sub PublishAnalysis()
'Use this macro to publish a Profit analysis as a cockpit.
'This macro will save an Excel worksheet to htm.
'In earlier versions the Excel worksheet was saved to pdf (old help files will still have descriptions of this).
'You also need the 'GenerateXMLForInsite' function.
Dim strFilePath As String
Dim strFileName As String
Dim strSheetName As String
Dim strPublishArea As String
Dim strHeightInPixels As String
Dim strWidthInPixels As String
Dim strActualHeight As String
Dim strActualWidth As String
'Publication folder and htm name
'THE FOLDER NAME MUST END WITH A BACKSLASH\
strFilePath = "\\filer2\cockpits\O51753AA\test1\"
strFileName = "test1.htm"
'Name of the Excel sheet you want to publish and the cell range on this sheet
strSheetName = "ExcelSheetToBePublished"
strPublishArea = "$A$1:$E$60"
strActualHeight = Worksheets("Cockpit Verkort Alles").Range("$A$1:$E$60").Height
strHeightInPixels = CStr(Round(strActualHeight * 1.322834646) + 1) + "px"
strActualWidth = Worksheets("Cockpit Verkort Alles").Range("$A$1:$E$60").Width
strWidthInPixels = CStr(Round(strActualWidth * 1.322834646) + 1) + "px"
ActiveWorkbook.PublishObjects.Add(xlSourceRange, "\\filer2\cockpits\O51753AA\test1\" & "test1.htm", "Cockpit Verkort Alles", "$A$1:$E$60", xlHtmlStatic, "Cockpit Verkort Alles").Publish (True)
'Generate xml file for publication in Profit InSite
GenerateXMLForInsite strHeightInPixels, strWidthInPixels, strFilePath, strFileName
End Sub
Function GenerateXMLForInsite(ByVal parHeightInPixels As String, ByVal parWidthInPixels As String, ByVal parFilePath As String, ByVal parFileName As String)
'Functie die een xml-bestand genereert om de analyse te kunnen publiceren in insite
'Variables
Dim objDom As New DOMDocument
Dim objCockpitElement As IXMLDOMElement
Dim objAttribute As IXMLDOMAttribute
objDom.appendChild objDom.createProcessingInstruction("xml", "version =""1.0"" encoding=""utf-8""")
Set objCockpitElement = objDom.appendChild(objDom.createElement("cockpit"))
Set objAttribute = objDom.createAttribute("startLocation")
objAttribute.Value = parFileName
objCockpitElement.Attributes.setNamedItem objAttribute
Set objAttribute = objDom.createAttribute("height")
objAttribute.Value = parHeightInPixels
objCockpitElement.Attributes.setNamedItem objAttribute
Set objAttribute = objDom.createAttribute("width")
objAttribute.Value = parWidthInPixels
objCockpitElement.Attributes.setNamedItem objAttribute
objDom.Save parFilePath & "insite.xml"
End Function
Alvast bedankt!
Robin
Graag verzoek ik om jullie help bij de volgende macro:
het gaat om de onderstreepte en zwartgedrukte regel. VBA blijft zeggen dat er een fout in die regel van de macro zit, maar ik zelf kom er niet uit; wat dit precies is. kunnen jullie mij misschien helpen?
Sub PublishAnalysis()
'Use this macro to publish a Profit analysis as a cockpit.
'This macro will save an Excel worksheet to htm.
'In earlier versions the Excel worksheet was saved to pdf (old help files will still have descriptions of this).
'You also need the 'GenerateXMLForInsite' function.
Dim strFilePath As String
Dim strFileName As String
Dim strSheetName As String
Dim strPublishArea As String
Dim strHeightInPixels As String
Dim strWidthInPixels As String
Dim strActualHeight As String
Dim strActualWidth As String
'Publication folder and htm name
'THE FOLDER NAME MUST END WITH A BACKSLASH\
strFilePath = "\\filer2\cockpits\O51753AA\test1\"
strFileName = "test1.htm"
'Name of the Excel sheet you want to publish and the cell range on this sheet
strSheetName = "ExcelSheetToBePublished"
strPublishArea = "$A$1:$E$60"
strActualHeight = Worksheets("Cockpit Verkort Alles").Range("$A$1:$E$60").Height
strHeightInPixels = CStr(Round(strActualHeight * 1.322834646) + 1) + "px"
strActualWidth = Worksheets("Cockpit Verkort Alles").Range("$A$1:$E$60").Width
strWidthInPixels = CStr(Round(strActualWidth * 1.322834646) + 1) + "px"
ActiveWorkbook.PublishObjects.Add(xlSourceRange, "\\filer2\cockpits\O51753AA\test1\" & "test1.htm", "Cockpit Verkort Alles", "$A$1:$E$60", xlHtmlStatic, "Cockpit Verkort Alles").Publish (True)
'Generate xml file for publication in Profit InSite
GenerateXMLForInsite strHeightInPixels, strWidthInPixels, strFilePath, strFileName
End Sub
Function GenerateXMLForInsite(ByVal parHeightInPixels As String, ByVal parWidthInPixels As String, ByVal parFilePath As String, ByVal parFileName As String)
'Functie die een xml-bestand genereert om de analyse te kunnen publiceren in insite
'Variables
Dim objDom As New DOMDocument
Dim objCockpitElement As IXMLDOMElement
Dim objAttribute As IXMLDOMAttribute
objDom.appendChild objDom.createProcessingInstruction("xml", "version =""1.0"" encoding=""utf-8""")
Set objCockpitElement = objDom.appendChild(objDom.createElement("cockpit"))
Set objAttribute = objDom.createAttribute("startLocation")
objAttribute.Value = parFileName
objCockpitElement.Attributes.setNamedItem objAttribute
Set objAttribute = objDom.createAttribute("height")
objAttribute.Value = parHeightInPixels
objCockpitElement.Attributes.setNamedItem objAttribute
Set objAttribute = objDom.createAttribute("width")
objAttribute.Value = parWidthInPixels
objCockpitElement.Attributes.setNamedItem objAttribute
objDom.Save parFilePath & "insite.xml"
End Function
Alvast bedankt!
Robin
[ Voor 7% gewijzigd door Verwijderd op 23-09-2014 16:12 ]