I don't know how to open a file in ASP. Here is my code which is not working.
<%
Dim vid_file
vid_file = Request.ServerVariables("APPL_PHYSICAL_PATH")& "cannon\pay\vid.dat"
Dim vkey_file
vkey_file = Request.ServerVariables("APPL_PHYSICAL_PATH")& "cannon\pay\vkey.dat"
dim fp1,f
set fp1 = Server.CreateObject("Scripting.FileSystemObject")
set f=fp1.OpenTextFile(Server.MapPath("vid_file"),8,true)
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fp1=Nothing
'Single Variable Declarations
dim fp2,f2
set fp2 = Server.CreateObject("Scripting.FileSystemObject")
'fExists=FileSysObj.FileExists(vid_file)
set f2=fp2.OpenTextFile(Server.MapPath("vkey_file"),8,true)
'set TextStreamObj = fp2.OpenTextFile(vkey_file,1,true)
'TextStreamObj.WriteLine("This text will be added to the end of file")
f2.WriteLine("This text will be added to the end of file")
f2.Close
set f2=Nothing
set fp2=Nothing
%>
<%
Dim vid_file
vid_file = Request.ServerVariables("APPL_PHYSICAL_PATH")& "cannon\pay\vid.dat"
Dim vkey_file
vkey_file = Request.ServerVariables("APPL_PHYSICAL_PATH")& "cannon\pay\vkey.dat"
dim fp1,f
set fp1 = Server.CreateObject("Scripting.FileSystemObject")
set f=fp1.OpenTextFile(vid_file,8,true)
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fp1=Nothing
'Single Variable Declarations
dim fp2,f2
set fp2 = Server.CreateObject("Scripting.FileSystemObject")
'fExists=FileSysObj.FileExists(vid_file)
set f2=fp2.OpenTextFile(vkey_file,8,true)
'set TextStreamObj = fp2.OpenTextFile(vkey_file,1,true)
'TextStreamObj.WriteLine("This text will be added to the end of file")
f2.WriteLine("This text will be added to the end of file")
f2.Close
set f2=Nothing
set fp2=Nothing
%>
Related
Just wanted to add information on the below post (but seems I cant).
https://safeweb.hsbcpb.com/https://stackoverflow.com/questions/39269911/nuance-power-pdf-automation-using-excel-vba-macro
The reference is now:
"C:\Program Files (x86)\Kofax\Power PDF 31\bin\PDFCore8_x64.dll"
even if called powerPDF and the documentation said so to create the with "powerdpdf.app", the following code work fine for me (just in case someone was looking for a solution like I did).
Function copy_pdf_values_wiht_nuance(path As String) As String
Dim PDFApp As Object
Dim dvOpenDoc As Object
Dim ddDoc As Object
Set PDFApp = CreateObject("nuancePDF.App")
Set dvOpenDoc = CreateObject("nuancePDF.DVDoc")
If dvOpenDoc.Open(path) = False Then
PDFApp.Exit
Exit Function
End If
Set ddDoc = dvOpenDoc.GetDDDoc()
PDFApp.MenuItemExecute ("SelectAll")
PDFApp.MenuItemExecute ("Copy")
PDFApp.Exit
'Set ddPage = ddDoc.AcquirePage(0)
'Set hl = CreateObject("NuancePDF.HiliteList")
'hr = hl.Add(12, 1)
'hr = hl.Add(52, 2)
'Set ts = ddPage.CreatePageHilite(hl)
'hr = dvOpenDoc.SetTextSelection(ts)
'dvOpenDoc.ShowTextSelect
Dim clipboard As MSForms.DataObject
Dim strContents As String
Set clipboard = New MSForms.DataObject
clipboard.GetFromClipboard
strContents = clipboard.GetText
copy_pdf_values_wiht_nuance = strContents
End Function
Copy and paste content of a PDF, having had the wrong reference.
I am not a programmer so not sure what to do here. I would like an option of adding an image file in a Microsoft Word document userform for MAC. I had used a code earlier which works perfectly in Windows but it doesn't work for MAC and gives a 5948 error. I had added a field for the image in the userform with a button to add the image and the final submit button. The add button should allow the user to insert any size image from the local folder.
The code I was using is given below:
Dim ImagePath As String
Private Sub CMDAddImage_Click()
Dim objFileDialog As Office.FileDialog
Set objFileDialog = Application.FileDialog(MsoFileDialogType.msoFileDialogFilePicker)
With objFileDialog
.AllowMultiSelect = False
.ButtonName = "File Picker"
.Title = "File Picker"
If (.Show > 0) Then
End If
If (.SelectedItems.Count > 0) Then
Call MsgBox(.SelectedItems(1))
ImagePath = .SelectedItems(1)
End If
End With
Image1.Picture = LoadPicture(ImagePath)
End Sub
And the code in submit button was:
Dim objWord
Dim objDoc
Dim objShapes
Dim objSelection
'Set objSelection = ActiveDocument.Sections
'objSelection.TypeText (vbCrLf & "One Picture will be inserted here....")
ActiveDocument.Bookmarks("Field04").Select
Set objShapes = ActiveDocument.InlineShapes
objShapes.AddPicture (ImagePath)
End
End Sub
How can I edit the code for Mac? In Mac it does not allow to add the file.
I have a Catia part where I have a few sketches on different planes. I need to be able to convert these sketches into 3D points which I copy to a new part document.
I have tried to use the Search and Selection commands in VB script in order to use a macro to pick up all the 2D points in my sketch and convert them to 3D points but to no avail.
Sub CATMain()
Set oSel = CATIA.ActiveDocument.Selection
strArray(0)=”Part”
Msgbox “Please select parts to join.”
sStatus = oSel.SelectElement3(strArray, “Select parts”, False, CATMultiSelTriggWhenUserValidatesSelection, false)
iCount = oSel.Count
For i= 1 to iCount
Set myObject2 = oSel.Item(i).value
oSel.Search “Name=Point,sel”
ReDim copies(iCount)
For k=1 to iCount
Set copies(k)=oSel.Item(k).Value
oSel.Add copies(k)
oSel.Copy
Next ‘k
Next ‘i
Set part2 = CATIA.Documents.Add(“CATPart”)
part2.Product.PartNumber = “My New Part”
Dim GSet1 As HybridBody
Set GSet1 = part2.Part.HybridBodies.Item(1)
GSet1.Name = “My Geometry”
Set partDocument2= CATIA.ActiveDocument
Dim ActSel As Selection
Set ActSel=partDocument2.Selection
ActSel.Add GSet1
ActSel.PasteSpecial(“CATPrtResultWithOutLink” )
ActSel.Clear
End Sub
You have to disassemble the sketch to get at the points as something you can copy
The disassemble command is exposed in VB via the HybridShapeFactory.AddNewDatums method.
Option Explicit
Sub CATMain()
Dim oPart As part
Set oPart = CATIA.ActiveDocument.part
Dim oHSF As HybridShapeFactory
Set oHSF = oPart.HybridShapeFactory
Dim sx As Sketch
Set sx = oPart.HybridBodies.item("Geometrical Set.1").HybridSketches.item("Sketch.1")
'make a temporary body
Dim targetGS As HybridBody
Set targetGS = oPart.HybridBodies.add
targetGS.name = "TMP_BODY___DELETE_ME"
'create a datum curve from the sketch
Dim sxRef As Reference
Set sxRef = oPart.CreateReferenceFromObject(sx)
'make a zero-translate from the sketch
'This is required because AddNewDatums functions needs a HybridShape feature
Dim oZero As HybridShapeTranslate
Set oZero = oHSF.AddNewTranslate(sxRef, oHSF.AddNewDirectionByCoord(0#, 0#, 1#), 0#)
Call targetGS.AppendHybridShape(oZero)
Call oPart.UpdateObject(oZero)
'now do the disassembly
Dim oZeroRef As Reference
Set oZeroRef = oPart.CreateReferenceFromObject(oZero)
'un-datum the curve by making a zero translate
Dim domains() As Variant
domains = oHSF.AddNewDatums(oZeroRef)
Dim i As Integer
For i = 0 To UBound(domains)
Call targetGS.AppendHybridShape(domains(i))
Next
Call oPart.Update
'now we can copy the resulting points...
Dim oSel As Selection
Set oSel = CATIA.ActiveDocument.Selection
Call oSel.add(targetGS)
Call oSel.Search("'Generative Shape Design'.Point,sel")
'copy paste into the new part
MsgBox ("There are " & oSel.count & " points ready to copy")
< YOUR COPY PASTE CODE GOES HERE>
'delete the temporary geo set
Call oHSF.DeleteObjectForDatum(oPart.CreateReferenceFromObject(targetGS))
End Sub
I'm trying to set a single page to be landscape, however every method I try changes the entire document rather than the section\paragraph I set PageSetup on. Here's an example, the first page should be portrait and the second should be landscape:
Dim wrdApp As Word.Application
Dim wrdDoc As Word._Document
Public Sub test()
Dim wrdSelection As Word.Selection
Dim wrdDataDoc As Word._Document
Dim sText As String
wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
wrdDataDoc = wrdApp.Documents.Open("C:\Temp\Doc1.docx")
wrdDataDoc.PageSetup.Orientation = WdOrientation.wdOrientPortrait
Dim oPara1 As Paragraph
sText = "Test Report Title"
oPara1 = wrdDataDoc.Content.Paragraphs.Add
oPara1.Range.Text = sText
oPara1.Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter
oPara1.Range.InsertParagraphAfter()
Dim para As Word.Paragraph = wrdDataDoc.Paragraphs.Add()
para.Range.InsertBreak()
wrdApp.Selection.GoTo(Word.WdGoToItem.wdGoToLine, Word.WdGoToDirection.wdGoToLast)
wrdDataDoc.Sections(1).PageSetup.Orientation = WdOrientation.wdOrientLandscape
wrdSelection = wrdApp.Selection()
wrdDataDoc.Tables.Add(wrdSelection.Range, NumRows:=9, NumColumns:=4)
With wrdDataDoc.Tables.Item(1)
'Code for table here
End With
End Sub
You need to insert a page break, try this:
oPara1.Range.InsertBreak Type:=wdSectionBreakNextPage
wrdDataDoc.Sections(wrdDataDoc.Sections.Count).PageSetup.Orientation = wdOrientLandscape
I have a vbs script which captures file information and then exports it to a csv file. I need to run the script on main drives such as C:\, E:\, I:\ and more, but each time I run for the main directory I get "Permission Denied" when I try to run it for a subfolder example C:\Program Files it works fine. I have tested this on different desktop machines and servers with full admin accounts and still get it.
What could be the issue with this code. test.vbs
Option Explicit
Dim objFS, objFld
Dim objArgs
Dim strFolder, strDestFile, blnRecursiveSearch
Dim strLines()
Dim i
Dim strCsv
i = 0
' 'Get the commandline parameters
' Set objArgs = WScript.Arguments
' strFolder = objArgs(0)
' strDestFile = objArgs(1)
' blnRecursiveSearch = objArgs(2)
'###################################
'MAKE SURE THESE VALUES ARE CORRECT
'###################################
strFolder = "C:\"
strDestFile = "C:\Output.csv"
blnRecursiveSearch = True
'Create the FileSystemObject
Set objFS=CreateObject("Scripting.FileSystemObject")
'Get the directory you are working in
Set objFld = objFS.GetFolder(strFolder)
'Now get the file details
GetFileDetails objFld, blnRecursiveSearch
'Write the csv file
Set strCsv = objFS.CreateTextFile(strDestFile, True)
strCsv.Write Join(strLines, vbCrLf)
'Close and cleanup objects
strCsv.Close
Set strCsv = Nothing
Set objFld = Nothing
Set strFolder = Nothing
Set objArgs = Nothing
Private Sub GetFileDetails(fold, blnRecursive)
Dim fld, fil
dim strLine(5)
If blnRecursive Then
'Work through all the folders and subfolders
For Each fld In fold.SubFolders
GetFileDetails fld, True
Next
End If
'Now work on the files
For Each fil in fold.Files
strLine(0) = fil.Path
strLine(1) = fil.Type
strLine(2) = fil.Size
strLine(3) = fil.DateCreated
strLine(4) = fil.DateLastModified
strLine(5) = fil.DateLastAccessed
Redim Preserve strLines(i)
strLines(i) = Join(strLine, ",")
i = i + 1
Next
end sub
Please advise and modify code if you know where the issue is.
If it's a permissions problem I would strongly recommend Process Monitor from Sysinternals to diagnose it. You should be able to watch the cscript process (or whatever is executing your script) and find out what kind of permission problem you're having.