I have an issue, have an AutoCAD file with a ton of data links and would like to update only the data links related to a speciffic table.
Simmilar to the functionality of selecting a table with data links, right clicking and selecting Update Table Data Links.
i have the following code:
Private Sub Update_table_data_link(tblRef As AcadTable)
ThisDrawing.SendCommand "DATALINKUPDATE" & vbCr & "U" & vbCr & "K" & vbCr
End Sub
It works but updates all the data links in the drawing (which is a problem) so a perfect solution would either let me get what links are associated to tblRef
and change the line to:
ThisDrawing.SendCommand "DATALINKUPDATE" & vbCr & "U" & vbCr & "D" & vbCr & "datalink_name_from_tblRef" & vbCr
or directly send the command to update the links to tblRef
After much digging around and a lot of help, here is the answer:
Private Sub Update_table_data_link(tblRef As AcadTable)
ThisDrawing.SendCommand "DATALINKUPDATE " & vbCr & "U" & vbCr & Ent2lspEnt(tblRef) & vbCr & vbCr
End Sub
Public Function Ent2lspEnt(entObj As AcadEntity) As String
'Designed to work with SendCommand, which can't pass objects.
'This gets an objects handle and converts it to a string
'of lisp commands that returns an entity name when run in SendCommand.
Dim entHandle As String
entHandle = entObj.Handle
Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function
note that "Update_table_data_link" has a table as input
Related
So I will try and be as clear as possible.
I am trying to make a macro that will populate and email with the following things:
Values from Listboxes
Writing for the main message
and a Table of values (which I've currently got being populated as a HTML body.
For example, I would like the email body to look as follows:
"Dear" [Name from preselected listbox]
"In order that we compile the latest update for the NAV please can you arrange the following information to be provided for" [The date]
[LIST THROUGH HTML]
"Please can you provide this information by the folowinf date"/....
I've currently got the list being pulled through correctly, but that has then stopped the vba body being entered. Therefore, the following code only pulls through the list.
Dim Addressee As String, SenRan As Range ' Define the receipient as words
Addressee = Application.VLookup(SourceLiBo.Value, Sheet1.Range("A1:B1000"), 2, False) 'finds the email address for chosen name
Set SenRan = ThisWorkbook.Sheets("Assets").Range("A1").CurrentRegion 'Selects the range of assets to be emailed.
With OEmail
.To = Addressee 'Send to addressee
.Subject = "Information Request " & Format(Date, "mmmm")
.Body = "Dear " & Me.SourceLiBo & "," & Chr(10) & _
"In order that we can compile the latest update for the NAV, please can you arrange the following information to be provided for " & Format(Date, "mmmm") & ":" & Chr(10) & _
""
.HTMLBody = rangetoHTML(SenRan)
End With
How is the best way to go about this in order to have all the data pull through. I would set variables with the strings wanted for the body and input it through .HMTLBody, but would that also allow me to pull through th listbox values in HMTLBody
I have now reworded it, thanks to braX explaining my errors. The code below (with the Ron Bruin Function) provides the correct answer.
With OEmail
.To = Addressee 'Send to addressee
.Subject = "Information Request " & Format(Date, "mmmm")
.HTMLBody = "Dear " & Me.SourceLiBo & "," & _
"<br><br>" & _
"In order that we can compile the latest update for the NAV, please can you arrange the following information to be provided for " & Format(Date, "mmmm") & ":" & _
"<br><br>" & _
rangetoHTML(SenRan) & _
"<br><br>" & _
"Please let us know if there are any additional purchases not reflected in the list above." & _
"<br><br>" & _
"Please can you provide this information no later than 10 working days from the date of this email to allow us to process all updates for delivery." & _
"<br><br>" & _
"Many Thanks"
End With
This is probably a simple task, but for some reason I’m not quite getting it right.
I want to save a copy of the active workbook to a different file. I have used a code in the past to do this with the date, but I want to remove the date. The code I used in the past is the following:
ActiveWorkbook.SaveCopyAs "P:\Wealth Management Products & Services\Investment Research & Communication\Structured Products\" &Format(dtdate) & " " & "Structured Product Tool" & " " & "Bloomberg" &".xlsm"
What I want is to remove the date, so the name will be: Structured Product Tool Bloomberg
I thought it would be the following:
ActiveWorkbook.SaveCopyAs "P:\Wealth Management Products Services\Investment Research & Communication\Structured Products\"Structured Product Tool" & " " & "Bloomberg" & ".xlsm"
But I’m getting an error.
Does anyone know the correct code for this?
Thanks, Peter
You are missing an ampersand & in your statement:
ActiveWorkbook.SaveCopyAs "P:\Wealth Management Products & Services\Investment" _
& "Research & Communication\Structured Products\" _
& "Structured Product Tool" & " " & "Bloomberg" & ".xlsm"
on my excel sheet the user can choose some video clips and arrange in different order to play as a vlc playlist. Unfortunately it can’t be guaranteed that the video file names haven’t any blanks.
To build the vlc playlist I use successfully:
Dim PL
PL = Shell("C:\Program Files\VideoLAN\VLC\VLC.exe " & certainPath & "\Movie6.flv" & " " & certainPath & "\Movie7.flv" & " " & certainPath & "\Movie8.flv ", 1)
'using "\Movie 6.flv" 'doesn't work of course
'using "\'Movie 6.flv'" 'doesn't work aswell
Is there another way to encapsulate file name with blanks?
thankfull for a hint.
Assuming that certainPath folder end with \ ( es. "C:\" ), this should work:
Dim PL
PL = Shell(chr(34) & "c:\Program Files\VideoLAN\VLC\vlc.exe " & chr(34) & chr(34) & certainPath & "Movie 6.flv" & chr(34) & " " & chr(34) & certainPath & "Movie 7.flv" & chr(34))
CHR is a function to returns the character from the ASCII table (the quotes in this case).
This question already has answers here:
How to enter newline character in Oracle?
(3 answers)
Closed 4 years ago.
I have written VBA code in excel to create a SP in oracle and it working fine.
But when I opened SP in oracle it showing entire code in single line. I have tried known ways to give line breaks but nothing works.
My actual VB code:
If sp_exist_chk_flag > 0 Then
Else
cmd_meta.CommandText = "create or replace PROCEDURE TEST_SP " & Chr(13) & _
"As" & Chr(13) & _
"REP DATA_REP.REP_ID%TYPE;" & Chr(13) & _
"SELECT REP_ID INTO REP FROM DATA_REP WHERE REP_NAME='xyz';" & Chr(13) & _
"COMMIT;" & Chr(13) & _
"END;"
cmd_meta.Execute
MsgBox "SP Created"
End If
In Oracle I can see SP is created as below
create or replace PROCEDURE TEST_SP As REP DATA_REP.REP_ID%TYPE; SELECT REP_ID INTO REP FROM DATA_REP WHERE REP_NAME='xyz'; COMMIT; END;
My actual SP is too long, so my vb code making it very long line.
Please help me on this with VB code or oracle command to look like an actual SP with proper line breaks in oracle.
Not sure if it will make a difference, but try using the vbCrLf constant instead of Chr(13).
If sp_exist_chk_flag > 0 Then
Else
cmd_meta.CommandText = "create or replace PROCEDURE TEST_SP " & vbCrLf & _
"As" & vbCrLf & _
"REP DATA_REP.REP_ID%TYPE;" & vbCrLf & _
"SELECT REP_ID INTO REP FROM DATA_REP WHERE REP_NAME='xyz';" & vbCrLf & _
"COMMIT;" & vbCrLf & _
"END;"
cmd_meta.Execute
MsgBox "SP Created"
End If
I'm working with legacy code here and I'm not sure how much I could or should change, but I have code that looks for something like "SIC CODE 4000"
However the data html database I pull it from (we use a copy and paste) has updated their code to have:
"SiC CODE
4000"
Currently the code is:
Const strSic = "SIC Code "
However I now need it to add line breaks.
I tried modifying the code to say:
Const strSic = "SIC Code" & Chr(10) & Chr(10) & Chr(10)
But I get a compile error saying "Constant expression required"
I tried using "SIC Code \n\n\n" but maybe I'm not thinking the right character for line break.
Any suggestions?
The code for a new line is vbNewLine:
Const strSic = "SIC Code" & vbNewLine & vbNewLine & vbNewLine
Update:
To be a bit more detailed see the VBA constants:
vbNewLine = Chr(13)+Chr(10) on Windows and Chr(13) on Mac
vbCr = Chr(13)
vbLf = Chr(10)
So if you only need Chr(10) you should use vbLf (like Excel Hero's answer).
Try this:
Const strSic = "SIC Code" & vbLf & vbLf & vbLf
Yes vbNewLine is the correct code : )